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
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.