0

我想使用 adldap php 从活动目录中获取所有用户显示名记录?

此代码可以获得单条记录。

if ($adldap->authenticate($username, $password)){
  $result=$adldap->user()->infoCollection("$username", array("*"))->displayName;
  print_r($result);
}

但我想从活动目录中获取所有显示名称记录,我尝试了以下代码,但不起作用

if ($adldap->authenticate($username, $password)){
      $result=$adldap->user()->infoCollection("*")->displayName; //show all record
      print_r($result);
    }

任何想法,非常感谢

4

1 回答 1

0

您需要通过搜索来收集所有用户——有关文档,请参阅https://github.com/adldap/adLDAP/blob/master/docs/SEARCH-FUNCTIONS.md。根据您的 AD 中有多少记录,您可能希望使用分页查询。有关信息,请参阅https://github.com/adldap/adLDAP/blob/master/docs/SEARCH-FUNCTIONS.md#paginate

获得结果集后,遍历结果集并获取每个用户的显示名称:

foreach($results as $result){
    echo $result['displayName'];
}
于 2020-09-08T15:59:59.037 回答