Search the LDAP Directory.

/*******************************************************
*     MYCPLUS Sample Code - https://www.mycplus.com     *
*                                                     *
*   This code is made available as a service to our   *
*      visitors and is provided strictly for the      *
*               purpose of illustration.              *
*                                                     *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/




ldap_search


\n");

	//pull names out into array so we can sort them
	for($i=0; $i < $entry["count"]; $i++)
	{
		//Note how we only use the first entry.  This
		//code assumes people only have one first name,
		//and one last name.
		$person[$i]["first"] = $entry[$i]["givenname"][0];
		$person[$i]["last"] = $entry[$i]["sn"][0];
	}

	//sort by last name, then first name using
	//compareEntry (defined above)
	usort($person, "compareEntry");


	//loop over each entry
	for($i=0; $i < $entry["count"]; $i++)
	{
		print($person[$i]["first"] . " " .
			$person[$i]["last"] . "
\n"); } //free memory used by search ldap_free_result($result); ?>