(PHP 4, PHP 5, PHP 7)
ldap_bind — 锟斤拷 LDAP 目录
$link_identifier
[, string $bind_rdn
= NULL
[, string $bind_password
= NULL
]] ) : bool使锟斤拷指锟斤拷锟斤拷 RDN 锟斤拷锟斤拷锟斤拷蠖ǖ锟� LDAP 目录锟斤拷
link_identifier
通锟斤拷 ldap_connect() 锟斤拷锟斤拷之锟襟返回碉拷 LDAP 锟斤拷锟接憋拷识锟斤拷
bind_rdn
bind_password
锟斤拷锟矫伙拷锟街革拷锟� bind_rdn
锟斤拷 bind_password
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷莅蠖ā锟�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 使锟斤拷 LDAP Bind
<?php
// using ldap bind
$ldaprdn = 'uname'; // ldap rdn or dn
$ldappass = 'password'; // associated password
// connect to ldap server
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}
?>
Example #2 Using LDAP Bind Anonymously
<?php
//using ldap bind anonymously
// connect to ldap server
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding anonymously
$ldapbind = ldap_bind($ldapconn);
if ($ldapbind) {
echo "LDAP bind anonymous successful...";
} else {
echo "LDAP bind anonymous failed...";
}
}
?>