当我测试 ldap_bind 时,它可以在我的测试机器上运行,因为它与我的 ldap 服务器在同一个域上,但是当我将代码移动到网络托管时
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in /home
我是从与 ldap 服务器在同一域中的浏览器访问它,所以主机应该可以访问 ldap 服务器?
<?php
// using ldap bind
$ldaprdn = 'user'; // ldap rdn or dn
$ldappass = 'pass'; // associated password
// connect to ldap server
$ldapconn = ldap_connect("server.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 & strlen($ldappass)>0) {
echo "H LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}
?>