如何使用PHP在LDAP中按类别进行分组

时间:2015-03-11 05:46:45

标签: php sorting ldap ldap-query

如何根据" ou"在LDAP中对结果进行分组或排列。 OU有4个或更多类别并正确显示。如何使用PHP和HTML执行此操作?请帮我。我是LDAP的新手

OU示例

   ou=web service
   ou=department
   ou=city

如何显示这样的结果?

   sn     dn                                        mail                 ou
   user   cn=user,ou=web service,dc=domain,dc=com   example@domain.com   web service
   sn     dn                                        mail                 ou
   user   cn=user,ou=department,dc=domain,dc=com   example@domain.com    department 

这是PHP数组

  $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>";

使用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] => example@domain.com
            )

        [1] => mail
        [count] => 2
        [dn] => uid=userid,ou=department,dc=doamin,dc=com
    )

0 个答案:

没有答案