From: [EMAIL PROTECTED] Operating system: Linux - RedHat 7.2 PHP version: 4.1.1 PHP Bug Type: LDAP related Bug description: if using URI, ldap_connect() returns resource ID when server does not exist
I'm running a very simple test script (see below) to test my ldap server connection. According to the docs, ldap_connect() is supposed to return an LDAP resource id on successful connect, or FALSE on error. When I run the code with a valid server URI ($ds = ldap_connect("ldap://ldap.example.com")), everything works fine. When I run it with a URI to a nonexistent LDAP server ($ds = ldap_connect("ldap://does.not.exist")), ldap_connect returns a resource ID anyway, so my script has no way of knowing anything is wrong until I try to bind or search. If I simply give a nonexistent hostname rather than a URI ($ds = ldap_connect("does.not.exist")) the function returns FALSE as documented. I built PHP 4.1.1 against the client libraries from OpenLDAP 2.0.21. Here's the full code of my test script: <?php $ds = ldap_connect("ldap://ldap.example.com/"); echo "connect result is ".$ds."<p>"; if($ds) { $r=ldap_bind($ds); echo "Bind result is ".$r."<p>"; $sr=ldap_search($ds, "ou=users,dc=example,dc=com", "uid=carljm"); echo "Search result is ".$sr."<p>"; echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>"; echo "Getting entries ...<p>"; $info = ldap_get_entries($ds, $sr); echo "Data for ".$info["count"]." items returned:<p>"; for ($i=0; $i<$info["count"]; $i++) { echo "dn is: ". $info[$i]["dn"] ."<br>"; echo "first cn entry is: ". $info[$i]["cn"][0] ."<br>"; echo "first uidNumber entry is: ". $info[$i]["uidnumber"][0] ."<p>"; } echo "Closing connection"; ldap_close($ds); ?> -- Edit bug report at http://bugs.php.net/?id=15637&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=15637&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15637&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15637&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15637&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=15637&r=support Expected behavior: http://bugs.php.net/fix.php?id=15637&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15637&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=15637&r=submittedtwice