PHP連接錯誤ldap_bind(): Unable to bind to server: Protocol error in
// using ldap bind
$ldaprdn = 'cn=admin,dc=test,dc=com'; // ldap rdn or dn
$ldappass = 'test1'; // associated password
// connect to ldap server
$ldapconn = ldap_connect("ldap://192.168.1.36",'389')
or die("Could not connect to LDAP server.");
//擦。。加上這個函數就不會報錯了。好像是要設置下級別。 ldap_bind(): Unable to bind to server: Protocol error in
if (ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3"."<br />;";
} else {
echo "Failed to set protocol version to 3"."<br />;";
}
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...";
}
}
exit;