[snip]
> I am running into a problem with my queries returning a limited number
of
> result entries.
[/snip]
Most LDAP servers set a limit, it is usually not a PHP problem. One way
to solve is to query by first letter of last name and throw into an
array (iterating through the alphabet).
function ldapUserList($username, $password, $ip="127.0.0.1"){
$arrLetters = array("A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z");
/* connect to AD server */
if(!$ds=ldap_connect($ip)){
echo "did not connect...please contact system
administrator or go back to try again";
}
/* set LDAP option */
$un = "domain\\".$username;
$upw = $password;
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ds, LDAP_OPT_SIZELIMIT, 0);
/* bind to AD server */
if(!$r=ldap_bind($ds, $un, $upw)){
echo 'You are not authorized and or, your login information
was incorrect<br />';
echo $un.": ".$upw."<br />\n";
} else {
$userArray = array();
foreach($arrLetters as $letter){
/*
* search AD for users with surnames (sn), valid
e-mail addresses (mail)
* and make sure that they are valid
(msExchHideFromAddessLists)
*/
$sr= @ldap_search($ds, "dc=domain, dc=local",
"(&(&(sn=".$letter."*)([EMAIL PROTECTED]))(!(msExchHideFromAddressLists=
TRUE)))");
$info = ldap_get_entries($ds, $sr);
if(0 != count($info)){
/* place all valid entries into a usable
array */
for ($i=0; $i<count($info); $i++) {
/* make sure the item being
pushed into the array is not empty */
if('' !=
$info[$i]["mailnickname"][0]){
//array_push($userArray,
$info[$i]["mailnickname"][0] . "+".$info[$i]["cn"][0] .
"+".$info[$i]["mail"][0]);
$fullname =
$info[$i]["cn"][0];
$arrFN = explode("
",$fullname);
$fullname = $arrFN[1].",
".$arrFN[0];
$readname = $arrFN[0]."
".$arrFN[1];
$tusername =
strtolower($info[$i]["samaccountname"][0]);
$tempArray =
array("username"=>$tusername, "fullname"=>$fullname,
"readname"=>$readname);
array_push($userArray,
$tempArray);
}
}
}
}
}
/* sort the user array alphabetically and re-align numeric key
*/
array_multisort($userArray[1], SORT_ASC, SORT_STRING);
return $userArray;
}
$userArray = ldapUserList($_SESSION['user'], $_SESSION['password'],
"127.0.0.1");
Sorry about the funky line breaks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php