<?php
// $ds is a valid LDAP\Connection instance for a directory server
// $mail is an email address provided by the user in a form
$base = "o=My Company, c=US";
$filter = "(mail=".ldap_escape($mail, "", LDAP_ESCAPE_FILTER).")";
$sr = ldap_search($ds, $base, $filter, array("sn", "givenname", "mail"));
$info = ldap_get_entries($ds, $sr);
echo $info["count"]." entries returned\n";
?>