I've just gotten an LDAP server running on a Yellowdog Linux box, but I can't seem to bind to it with PHP except anonymously. I can do command-line queries just fine, and I can bind anonymously from PHP without problem as well. But when I try to pass ldap_bind a username or username and password, I get the following warning:
Warning: ldap_bind(): Unable to bind to server: Invalid DN syntax in /usr/local/webfiles/test.php on line 23
I'm just giving it plaintext usernames and passwords; what more does it want? I've done a fair amount of work with PHP/LDAP binding, and I'm not doing anything substantially different here. Is this maybe a problem with the way I've set up my LDAP server? I've reinstalled LDAP with a different backend since I installed PHP; could that be causing the problem? Thanks for your help.
The code of my test script follows:
$ds = ldap_connect("students.NebrWesleyan.edu");
if ($ds) {
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3\n";
} else {
echo "Failed to set protocol version to 3\n";
}
$basedn = "dc=students,dc=NebrWesleyan,dc=edu";
$query = "uid=*";
$username = "saintp";
$password = "******";
$r = ldap_bind($ds, $username);
if ($r) {
$sr = ldap_search($ds, $basedn, $query);
$info = ldap_get_entries($ds, $sr);
print "\n\nusername:";
print_r($info);
} else {
print "username failed, trying user/pass\n";
}
$r = ldap_bind($ds, $username, $password);
if ($r) {
$sr = ldap_search($ds, $basedn, $query);
$info = ldap_get_entries($ds, $sr);
print "\n\nuser/pass:";
print_r($info);
} else {
print "user/pass failed\n";
}
}