I figured out the multiple OU thanks to the post of pyther. But a few questions. I have 10 different OU's to search and while I could code it the long way by defining each ou and retyping the same DC's over and over. Is there a way to loop that or use an array just for the different OU names?
--- userfind.php.original 2010-10-02 22.000000000 -0400
+++ userfind.php 2010-10-02 22.000000000 -0400
@@ -4,13 +4,13 @@
// START EDIT
//Replace this with the DN of the base OU you want to search
-$search_user_dn = "OU=Users,DC=domain,DC=local";
//perhaps use a nested array here to just provide OU names instead of typing DC=ndcls,DC=local over and over again?
+$search_user_dn = array(array ("OU=Staff,OU=Faculty,OU=group1,OU=group2,OU=group3"),DC=ndcls,DC=locall");
// STOP EDIT
$inforequired = array("displayName","mail");
@@ -33,8 +33,9 @@ else
$curName.='*';
$filter="(&(displayName=$curName)(objectCategory=person))";
}
- $user_result = ldap_search($ds,$search_user_dn,$filter,$inforequired);
- $user_info = ldap_get_entries($ds,$user_result);
//perhaps use a foreach loop here to cycle through the 10 or so OU entries I'd need?
+ $user_result = array(ldap_search($ds,$search_user_dn,$filter,$inforequired), ldap_search($ds,$search_user_dn,$filter,$inforequired));
+ $user_info = array_merge(ldap_get_entries($ds,$user_result),ldap_get_entries($ds,$user_result));
+ asort($user_info);
header("Content-Type: application/json");
echo"{\"results\": [";
$arr=Array();