函数名:ldap_bind_ext()
适用版本:PHP 5 >= 5.4.0, PHP 7
用法:ldap_bind_ext()函数用于扩展的LDAP绑定操作。它提供了更多的灵活性和控制,允许您指定更多的绑定选项。
语法:bool ldap_bind_ext(resource $link_identifier, string $bind_rdn = null, string $bind_password = null, array $serverctrls = [], array &$resp_ctrls = null)
参数:
返回值:成功时返回TRUE,失败时返回FALSE。
示例:
// 创建LDAP连接
$ldapconn = ldap_connect("ldap.example.com");
// 绑定操作
$bind_rdn = "cn=admin,dc=example,dc=com";
$bind_password = "password";
$bind_result = ldap_bind_ext($ldapconn, $bind_rdn, $bind_password);
if ($bind_result) {
echo "LDAP绑定成功";
} else {
echo "LDAP绑定失败";
}
// 关闭LDAP连接
ldap_close($ldapconn);
注意事项: