&reftitle.examples;
Basic usage Retrieve information for all entries where the surname starts with "S" from a directory server, displaying an extract with name and email address. LDAP search example LDAP query test"; echo "Connecting ..."; $ds=ldap_connect("localhost"); // must be a valid LDAP server! echo "connect result is " . $ds . "
"; if ($ds) { echo "Binding ..."; $r=ldap_bind($ds); // this is an "anonymous" bind, typically // read-only access echo "Bind result is " . $r . "
"; echo "Searching for (sn=S*) ..."; // Search surname entry $sr=ldap_search($ds, "o=My Company, c=US", "sn=S*"); echo "Search result is " . $sr . "
"; echo "Number of entries returned is " . ldap_count_entries($ds, $sr) . "
"; echo "Getting entries ...

"; $info = ldap_get_entries($ds, $sr); echo "Data for " . $info["count"] . " items returned:

"; for ($i=0; $i<$info["count"]; $i++) { echo "dn is: " . $info[$i]["dn"] . "
"; echo "first cn entry is: " . $info[$i]["cn"][0] . "
"; echo "first email entry is: " . $info[$i]["mail"][0] . "


"; } echo "Closing connection"; ldap_close($ds); } else { echo "

Unable to connect to LDAP server

"; } ?> ]]>