Greets,
I am having a strange issue with my ldap_connect and ldap_bind commands. I have a program:
<?
$ldap = ldap_connect("192.168.0.1");
echo "link = $ldap<br>";
if($ldap) {
echo "Connected<br>";
if(ldap_bind($ldap)) {
echo "Bound anon<br>";
} else {
echo "Unable to bind anon<br>";
}
} else {
echo "Unable to connect<br>";
}
?>
It seems to work OK, with output:
link = Resource id #1
Connected
Bound anon
However, if I use a FQDN that resolves to the IP address specified above in the connect string, it connects but the
bind fails:
<?
$ldap = ldap_connect("ldap://ldap_server.myorg.com/");
echo "link = $ldap<br>";
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 2);
if($ldap) {
echo "Connected<br>";
if(ldap_bind($ldap)) {
echo "Bound anon<br>";
} else {
echo "Unable to bind anon<br>";
}
} else {
echo "Unable to connect<br>";
}
?>
Shows:
link = Resource id #1
Connected
Warning: LDAP: Unable to bind to server: Can't contact LDAP server in test_ldap.php on line 26
Unable to bind anon
I'm using PHP 4.1.2 and OpenLDAP $Id: ldap.c,v 1.94.2.3 2001/12/01 14:17:43 venaas Exp $.
I can use the FQDN without issue from the command line. I even tried playing with the ldap_set_option:
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
-and-
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 2);
Neither of these makes any difference.
Any ideas, anyone?
Thanks,
Jason