5

I have an active directory record of users with ou's and subou's. I want to get the whole tree structure of the AD.

for example,

- Group A
    - Sub Group a1
    - Sub Group a2
 - Group B
    - Sub Group b1
    - Sub Group b2
 - Group C
    - Sub Group c1
    - Sub Group c2

I have got a list of all ou's and subou's. but I want it as a structure like above example.

My code:

$ldap_base_dn = 'DC=example,DC=com'; 
$filter="(objectClass=organizationalunit)";
$arr= array("dn", "ou");
$sr=ldap_search($ldap_connection, $ldap_base_dn, $filter, $arr);
$info = ldap_get_entries($ldap_connection, $sr);
for ($i=0; $i < $info["count"]; $i++) {
  echo $info[$i]["dn"]."<br>";
} 
kmoser
  • 8,780
  • 3
  • 24
  • 40

0 Answers0