dcparham Posted June 29, 2009 Share Posted June 29, 2009 Php ldap error: Can't contact LDAP server unsure if this qualifies as strictly an "ldap" technical question, or PHP, but my PHP code keeps generating error: Warning: ldap_search() [function.ldap-search]: Search: Can't contact LDAP server in [path and file name here] bool(false) [var_dump function gives the bool(false).] it appears to connect using ID/PW just fine[altering it makes it fail] : [code=php:0] phpinfo(); //shows LDAP module is installed in PHP $ldapHost = "ldap://ipaddresshere"; $ldapPort = "363"; //originally using port 389; some site said try 636 //see (URL address blocked: See forum rules)/node/99009 - references using SSL //another site said they fixed error "can't contact LDAP server" by using port: 363 $ldapUser = "the userid works"; $ldapPswd = "the pswd works"; $ldapLink = ldap_connect($ldapHost, $ldapPort) or die("Can't establish LDAP connection"); ldap_bind($ldapLink, $ldapUser, $ldapPswd) or die("Can't bind to the server"); //$results = ldap_search($ldapLink, $dn, "givenName=Ann"); $dn = "CN=Abe Lincoln,DC=alincoln"; $results = ldap_search($ldapLink, $dn, "givenName=Ann"); var_dump($results); //note: "ldap_read" function creates same error. [end php code] thanks for help with this! Quote Link to comment Share on other sites More sharing options...
Asheeown Posted June 29, 2009 Share Posted June 29, 2009 I think your filter on your search is invalid, at least that's the error I get when I screw up my filter. Change your filter to a variable and do something like this: $filter="(CN=Ann Frank)"; Lol, just need to replace the last name with something real. Quote Link to comment Share on other sites More sharing options...
dcparham Posted June 29, 2009 Author Share Posted June 29, 2009 well, guess what - i changed the code to this: [code=php:0] $filter="(CN=John Smith)"; $results = ldap_search($ldapLink, $dn, $filter); [/code] ...and for a brief few refreshes, gave a msg like "protocol resource(4)...", *soooomething* like that, but not the same old error. then i added another $filter "(o=Exchange)" and it failed; then i went back to the example above, and the same old error. basically, not working again. not sure the $filter syntax is right/trying various ones i see in code samples here and there. thank you very much for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.