ldap_bind problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a basic script for querying an ldap server. It works fine from
my college's production server, but not from another server in the
network, though I have been assured access should be allowed from

It fails at the ldap_bind() function. This function only returns a
boolean value. How might I retrieve a meaninful error message? Any
ideas where the problem is likely to lie, with this basic info?

Here is the code.

 echo "<h3>LDAP query test</h3>";
 echo "<B>Connecting ...</B><BR>";

 $ds=ldap_connect("xxxxx.xxxxx.ac.uk"); // working address supplied
 echo "connect result is ".$ds."<p>";

 if ($ds) {
     echo "Binding ...(anon)...";
     echo "Bind result is ".$r."<p>";

     echo "Searching for <B>$myclient</B> ...";
     // Search surname entry
     $sr=ldap_search($ds,"OU=STAFF, OU=DS, OU=SEC, O=LINST",
     echo "Search result is ".$sr."<p>";

     echo "Number of entires returned is

     echo "Getting entries ...<p>";
     $info = ldap_get_entries($ds, $sr);
     echo "Data for ".$info["count"]." items returned:<p>";
     echo "<HR>";

     for ($i=0; $i<$info["count"]; $i++) {
         echo "Full name (fullname) entry is: ".
$info[$i]["fullname"][0] ."<br>";
         echo "Job title (title) entry is: ". $info[$i]["title"][0]
         echo "Common name (cn) entry is: ". $info[$i]["cn"][0]
         echo "E-mail (mail) entry is: ". $info[$i]["mail"][0] ."<br>";
         echo "Telephone (telephonenumber) entry is: ".
         echo "Domain (dn) is: ". $info[$i]["dn"] ."<P><HR>\n";

       echo printall($info[$i]);


     echo "<P><B>Closing connection</B>";

 } else {
     echo "<h4>Unable to connect to LDAP server</h4>";

Any suggestions welcome.

Re: ldap_bind problem

downlode@gmail.com wrote:
Quoted text here. Click to load it

You can get the error or error number of the last command executed with
ldap_error() and ldap_errno().  See the following:


Site Timeline