ID: 15637 Comment by: mitteljc at e-i dot com Reported By: cjm46543 at hotmail dot com Status: Analyzed Bug Type: Documentation problem Operating System: Linux - RedHat 7.2 PHP Version: 4.4.0-dev New Comment:
My solution was to go one step further by using 'ldap_bind' to test the connection : $ds=ldap_connect("titi.tata.net"); [EMAIL PROTECTED]($ds,"cn=toto","tutu"); if ($r) { bla bla bla } else die("LDAP server not accessed !"); The '@' before 'ldap_bind' disables Warning dysplay. Previous Comments: ------------------------------------------------------------------------ [2004-05-03 17:33:57] sanjay_ichalkaranje at yahoo dot com I was trying to test my code which supposed to tell me whether a LDAP server is alive and rechable or not. But no matter what IP address I specified in ldap_connect it returned a valid resource. I found a way out by first pinging the server to know whether its alive and then trying to bind to know whether it is running LDAP. ------------------------------------------------------------------------ [2003-06-27 08:17:50] iane at sussex dot ac dot uk I can't get ldap_connect to return false, even when I pass an invalid URI or an invalid hostname. At least, I think ".*&%^$ldap.central.susx.ac.uk" is an invalid host name, and so is "4". They both return ldap connection resources, though. It is important, because I need to be able to test the hostname validity so that i know whether the problem with the host is that (a) it doesn't exist (b) it is down (c) the ldap service is down. ------------------------------------------------------------------------ [2003-05-04 05:17:43] gsivathanu at msn dot com So, is there a way to find whether the LDAP server is valid or not ? Gopalan Sivathanu ------------------------------------------------------------------------ [2003-04-01 11:04:14] egeczi at nospamplease dot dist113 dot org This is not just a documentation problem. Not only does $ldap_connection = ldap_connect("does.not.exist") return a resource id when it obviously shouldn't, but ldap_bind($ldap_connection, 'username', 'password') also returns true. If the actual connect occurs with ldap_bind(), why does it return true for a server that does not exist? Regards. ------------------------------------------------------------------------ [2003-02-28 03:52:03] korte-php at et dot rub dot de Rather anoying though since ldap_bind also fails when using a wrong password... only looking at bind fails doen't neccessarily mean, that the ldap server is down :( ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/15637 -- Edit this bug report at http://bugs.php.net/?id=15637&edit=1