mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-17 21:16:57 +08:00
136 lines
7.3 KiB
HTML
136 lines
7.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Connect to an LDAP server</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.ldap-connect" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">ldap_connect</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ldap_connect</span> — <span class="dc-title">Connect to an LDAP server</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.ldap-connect-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>ldap_connect</strong></span>
|
|
([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 389</span></span>
|
|
]] ) : <span class="type">resource</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Creates an LDAP link identifier and checks whether the given
|
|
<code class="parameter">host</code> and <code class="parameter">port</code> are plausible.
|
|
</p>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<span class="simpara">
|
|
This function does <em class="emphasis">not</em> open a connection.
|
|
It checks whether the given parameters are plausible and can be used
|
|
to open a connection as soon as one is needed.
|
|
</span>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.ldap-connect-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">host</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
This field supports using a hostname or, with OpenLDAP 2.x.x and
|
|
later, a full LDAP URI of the form <em>ldap://hostname:port</em>
|
|
or <em>ldaps://hostname:port</em> for SSL encryption.
|
|
</p>
|
|
<p class="para">
|
|
You can also provide multiple LDAP-URIs separated by a space as one string
|
|
</p>
|
|
<p class="para">
|
|
Note that <em>hostname:port</em> is not a supported LDAP URI as the schema is missing.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">port</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The port to connect to. Not used when using LDAP URIs.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.ldap-connect-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a positive LDAP link identifier when the provided hostname/port combination or LDAP URI
|
|
seems plausible. It's a syntactic check of the provided parameters but the server(s) will not
|
|
be contacted! If the syntactic check fails it returns <strong><code>FALSE</code></strong>.
|
|
When OpenLDAP 2.x.x is used, <span class="function"><strong>ldap_connect()</strong></span> will always
|
|
return a <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span> as it does not actually connect but just
|
|
initializes the connecting parameters. The actual connect happens with
|
|
the next calls to ldap_* funcs, usually with
|
|
<span class="function"><a href="ldap_bind.html" class="function">ldap_bind()</a></span>.
|
|
</p>
|
|
<p class="para">
|
|
If no arguments are specified then the link identifier of the already
|
|
opened link will be returned.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.ldap-connect-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-5389">
|
|
<p><strong>Example #1 Example of connecting to LDAP server.</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// LDAP variables<br /></span><span style="color: #0000BB">$ldaphost </span><span style="color: #007700">= </span><span style="color: #DD0000">"ldap.example.com"</span><span style="color: #007700">; </span><span style="color: #FF8000">// your ldap servers<br /></span><span style="color: #0000BB">$ldapport </span><span style="color: #007700">= </span><span style="color: #0000BB">389</span><span style="color: #007700">; </span><span style="color: #FF8000">// your ldap server's port number<br /><br />// Connecting to LDAP<br /></span><span style="color: #0000BB">$ldapconn </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldaphost</span><span style="color: #007700">, </span><span style="color: #0000BB">$ldapport</span><span style="color: #007700">)<br /> or die(</span><span style="color: #DD0000">"Could not connect to </span><span style="color: #0000BB">$ldaphost</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="example" id="example-5390">
|
|
<p><strong>Example #2 Example of connecting securely to LDAP server.</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// make sure your host is the correct one<br />// that you issued your secure certificate to<br /></span><span style="color: #0000BB">$ldaphost </span><span style="color: #007700">= </span><span style="color: #DD0000">"ldaps://ldap.example.com/"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Connecting to LDAP<br /></span><span style="color: #0000BB">$ldapconn </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldaphost</span><span style="color: #007700">)<br /> or die(</span><span style="color: #DD0000">"Could not connect to </span><span style="color: #007700">{</span><span style="color: #0000BB">$ldaphost</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.ldap-connect-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="ldap_bind.html" class="function" rel="rdfs-seeAlso">ldap_bind()</a> - 绑定 LDAP 目录</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |