sorting - How to group by categories in LDAP using PHP
250
How to group or arrange the results in LDAP according to "ou". OU have 4 or more categories and display it properly. How to do this with PHP and HTML? Please help me. I'm new in LDAP
OU example
ou=web service
ou=department
ou=city
How to do display the result like this?
sn dn mail ou
user cn=user,ou=web service,dc=domain,dc=com [email protected] web service
sn dn mail ou
user cn=user,ou=department,dc=domain,dc=com [email protected] department
Here's the PHP array
$dn = 'dc=domain,dc=com';
$filter = "(|(sn=$person*)(fullname=$person*))";
$ldaparray = array ("ou", "sn", "fullname", "mail");
$sr=ldap_search($ldapconn, $dn, $filter, $ldaparray);
$info = ldap_get_entries($ldapconn, $sr);
echo "<pre>";
print_r ($info);
echo "</pre>";
Output using print_r
Array
(
[count] => 1409
[0] => Array
(
[sn] => Array
(
[count] => 1
[0] => user
)
[0] => sn
[count] => 1
[dn] => cn=username,ou=web service,dc=domain,dc=com
)
[1] => Array
(
[sn] => Array
(
[count] => 1
[0] => user
)
[0] => sn
[mail] => Array
(
[count] => 1
[0] => [email protected]
)
[1] => mail
[count] => 2
[dn] => uid=userid,ou=department,dc=doamin,dc=com
)