2010-03-28 22:10:10 +00:00
<?xml version="1.0" encoding="utf-8"?>
2009-07-11 07:50:41 +00:00
<!-- $Revision$ -->
2007-06-20 22:25:43 +00:00
<refentry xml:id= "function.ldap-bind" xmlns= "http://docbook.org/ns/docbook" >
2007-02-04 22:46:33 +00:00
<refnamediv >
<refname > ldap_bind</refname>
<refpurpose > Bind to LDAP directory</refpurpose>
</refnamediv>
2007-02-04 22:48:23 +00:00
<refsect1 role= "description" >
&reftitle.description;
2007-02-04 22:46:33 +00:00
<methodsynopsis >
<type > bool</type> <methodname > ldap_bind</methodname>
<methodparam > <type > resource</type> <parameter > link_identifier</parameter> </methodparam>
2010-05-03 17:10:04 +00:00
<methodparam choice= "opt" > <type > string</type> <parameter > bind_rdn</parameter> <initializer > &null; </initializer> </methodparam>
<methodparam choice= "opt" > <type > string</type> <parameter > bind_password</parameter> <initializer > &null; </initializer> </methodparam>
2007-02-04 22:46:33 +00:00
</methodsynopsis>
<para >
2007-02-04 22:48:23 +00:00
Binds to the LDAP directory with specified RDN and password.
</para>
</refsect1>
<refsect1 role= "parameters" >
&reftitle.parameters;
<para >
<variablelist >
<varlistentry >
<term > <parameter > link_identifier</parameter> </term>
<listitem >
<para >
An LDAP link identifier, returned by <function > ldap_connect</function> .
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > bind_rdn</parameter> </term>
<listitem >
<para >
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > bind_password</parameter> </term>
<listitem >
<para >
</para>
</listitem>
</varlistentry>
</variablelist>
2007-02-04 22:46:33 +00:00
</para>
<para >
2017-01-12 18:17:41 +00:00
If <parameter > bind_password</parameter>
is not specified or is empty, an anonymous bind is attempted. The <parameter > bind_dn</parameter> can also be left empty for an anonymous bind. This is defined in https://tools.ietf.org/html/rfc2251#section-4.2.2
2007-02-04 22:46:33 +00:00
</para>
2007-02-04 22:48:23 +00:00
</refsect1>
<refsect1 role= "returnvalues" >
&reftitle.returnvalues;
<para >
&return.success;
</para>
</refsect1>
<refsect1 role= "examples" >
&reftitle.examples;
2007-02-04 22:46:33 +00:00
<para >
<example >
<title > Using LDAP Bind</title>
<programlisting role= "php" >
2002-12-09 03:27:15 +00:00
< ![CDATA[
< ?php
// using ldap bind
$ldaprdn = 'uname'; // ldap rdn or dn
$ldappass = 'password'; // associated password
// connect to ldap server
2002-12-09 20:25:54 +00:00
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
2002-12-09 03:27:15 +00:00
// binding to ldap server
2002-12-09 20:25:54 +00:00
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
2002-12-09 03:27:15 +00:00
// verify binding
2002-12-09 20:25:54 +00:00
if ($ldapbind) {
2002-12-09 03:27:15 +00:00
echo "LDAP bind successful...";
2002-12-09 20:25:54 +00:00
} else {
2002-12-09 03:27:15 +00:00
echo "LDAP bind failed...";
2002-12-09 20:25:54 +00:00
}
2007-02-04 22:46:33 +00:00
2002-12-09 03:27:15 +00:00
}
?>
]]>
2007-02-04 22:46:33 +00:00
</programlisting>
</example>
<example >
<title > Using LDAP Bind Anonymously</title>
<programlisting role= "php" >
2002-12-09 03:27:15 +00:00
< ![CDATA[
< ?php
//using ldap bind anonymously
// connect to ldap server
2002-12-09 20:25:54 +00:00
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
2002-12-09 03:27:15 +00:00
// binding anonymously
2002-12-09 20:25:54 +00:00
$ldapbind = ldap_bind($ldapconn);
2002-12-09 03:27:15 +00:00
2002-12-09 20:25:54 +00:00
if ($ldapbind) {
2002-12-09 03:27:15 +00:00
echo "LDAP bind anonymous successful...";
2002-12-09 20:25:54 +00:00
} else {
2002-12-09 03:27:15 +00:00
echo "LDAP bind anonymous failed...";
2002-12-09 20:25:54 +00:00
}
2007-02-04 22:46:33 +00:00
2002-12-09 17:22:39 +00:00
}
2007-02-04 22:46:33 +00:00
2002-12-09 03:27:15 +00:00
?>
]]>
2007-02-04 22:46:33 +00:00
</programlisting>
</example>
</para>
</refsect1>
2007-02-04 22:48:23 +00:00
2007-02-23 00:47:06 +00:00
<refsect1 role= "seealso" >
&reftitle.seealso;
<para >
<simplelist >
<member > <function > ldap_unbind</function> </member>
</simplelist>
</para>
</refsect1>
2007-02-04 22:46:33 +00:00
</refentry>
2002-04-15 00:12:54 +00:00
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
2009-09-25 07:04:39 +00:00
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
2002-04-15 00:12:54 +00:00
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->