Jump to content

Recommended Posts

see below the code, then the OUTPUT.  the output indicates no errors, yet the results appear empty.  i just do not know at this point why it produces nothing.  something missing??  i took out all the filters so as to trying getting any/all data via the query, to no avail.  can someone help??

 

####################################################

<?php

// basic sequence with LDAP is connect, bind, search, interpret search

// result, close connection

 

echo "<h3>LDAP query test</h3>";

echo "Connecting ...";

$ldapHost="***";

//can also use "***"

$ldapPort="***";

$ldapUser = "***";

$ldapPswd = "***";

$ldapConn=ldap_connect($ldapHost, $ldapPort)

or die("Can't establish LDAP connection");  // must be a valid LDAP server!

 

//from PHP and LDAP[p356-357] in "Beginning PHP5 and MySQL[iSBN#1-893115-51-8]

ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION,3);

ldap_start_tls($ldapConn);

 

echo "connect result is " . $ldapConn . "<br />";

 

echo "[ldap_error($ldapConn): ".ldap_error ($ldapConn)."]<BR>";

echo "[ldap_err2str (ldap_error ($ldapConn))]: ". ldap_err2str (ldap_error ($ldapConn))."<BR>";

if ($ldapConn) {

    echo "Binding ...";

    $ldapBind=ldap_bind($ldapConn, $ldapUser, $ldapPswd)

or die("Can't bind to the server.");    // this is an "anonymous" bind, typically

                          // read-only access

    echo "Bind result is " . $ldapBind . "<br />";

 

  // echo "Searching for (sn=S*) ..."; original

  echo "Searching for (s=*) ...";

 

    $searchResults=ldap_search($ldapConn);

 

    echo "Search result is " . $searchResults . "<br />";

 

    echo "Number of entires returned=" . ldap_count_entries($ldapConn, $searchResults) . "<br />";

 

    echo "Getting entries ...<p>";

    $info = ldap_get_entries($ldapConn, $searchResults);

    echo "Data for " . $info["count"] . " items returned:<p>";

 

    for ($i=0; $i<$info["count"]; $i++) {

        echo "dn is: " . $info[$i]["dn"] . "<br />";

        echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";

        echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";

    }

 

    echo "Closing connection";

    ldap_close($ldapConn);

 

} else {

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

}

?>

####################################################

 

  ************

  * the OUTPUT *

  ************

LDAP query test

Connecting ...connect result is Resource id #1

[ldap_error(Resource id #1): Decoding error]

[ldap_err2str (ldap_error (Resource id #1))]: Success

Binding ...Bind result is 1

Searching for (s=*) ...Search result is

Number of entires returned=

Getting entries ...

Data for items returned:

 

Closing connection

#######################################################

can someone help??

Link to comment
https://forums.phpfreaks.com/topic/86687-phpldap-no-errors-but-no-results/
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.