Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4397

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-compare.html">ldap_compare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ldap-control-paged-result-response.html">ldap_control_paged_result_response</a></div>
 <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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> &mdash; <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">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <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>
  ]] )</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">Parameters</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">Return Values</h3>
  <p class="para">
   Returns a positive LDAP link identifier when the provided hostname/port combination or LDAP URI
   seems plausible. It&#039;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="function.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">Examples</h3>
  <p class="para">
   <div class="example" id="example-5517">
    <p><strong>Example #1 Example of connecting to LDAP server.</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;LDAP&nbsp;variables<br /></span><span style="color: #0000BB">$ldaphost&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"ldap.example.com"</span><span style="color: #007700">;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;your&nbsp;ldap&nbsp;servers<br /></span><span style="color: #0000BB">$ldapport&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">389</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;your&nbsp;ldap&nbsp;server's&nbsp;port&nbsp;number<br /><br />//&nbsp;Connecting&nbsp;to&nbsp;LDAP<br /></span><span style="color: #0000BB">$ldapconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldaphost</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$ldapport</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;</span><span style="color: #0000BB">$ldaphost</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
   <div class="example" id="example-5518">
    <p><strong>Example #2 Example of connecting securely to LDAP server.</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;make&nbsp;sure&nbsp;your&nbsp;host&nbsp;is&nbsp;the&nbsp;correct&nbsp;one<br />//&nbsp;that&nbsp;you&nbsp;issued&nbsp;your&nbsp;secure&nbsp;certificate&nbsp;to<br /></span><span style="color: #0000BB">$ldaphost&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"ldaps://ldap.example.com/"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Connecting&nbsp;to&nbsp;LDAP<br /></span><span style="color: #0000BB">$ldapconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldaphost</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;</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">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ldap-connect-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ldap-bind.html" class="function" rel="rdfs-seeAlso">ldap_bind()</a> - Bind to LDAP directory</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-compare.html">ldap_compare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ldap-control-paged-result-response.html">ldap_control_paged_result_response</a></div>
 <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>