Jump to content

Php ldap error: Can't contact LDAP server


dcparham

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/164114-php-ldap-error-cant-contact-ldap-server/
Share on other sites

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.