2

So I just got started with LDAP, and was reading this tutorial on LDAP with PHP.

http://www.devshed.com/c/a/PHP/Using-PHP-With-LDAP-part-1/4/

There, once the result set is obtained. There were two commands/functions I came across...

    <?php // print number of entries found 
    echo "Number of entries found: " . ldap_count_entries($conn, $result) . "<p>"; ?>

and

  <?php // get entry data as array
  $info = ldap_get_entries($conn, $result); 
  // iterate over array and print data for each entry 
  for ($i=0; $i<$info["count"]; $i++) { echo "dn is: ". $info[$i]["dn"] ."<br>";
  echo "first cn is: ". $info[$i]["cn"][0] ."<br>";
  echo "first email address is: ". $info[$i]["mail"][0] ."<p>"; 
  } ?>

So, in what ways do ldap_count_entries and $info["count"] differ?

Thanks in advance!

1 Answer 1

1

As far as I know, the difference is mainly between whether you have to retrieve the results from the server or not.

To get $info['count'] you have to retrieve the complete result from the server via ldap_get_entries which might be a lengthy thing depending on the size of the result and the connection to your LDAP-Server.

To check whether it's worth the effort you can get the size of the resultset with ldap_count entries and depending on that result your application can decide what to do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.