I would like to get all user displayname record form active directory using adldap php?
this code can get the single record.
if ($adldap->authenticate($username, $password)){
$result=$adldap->user()->infoCollection("$username", array("*"))->displayName;
print_r($result);
}
but I want to get all display name record form active directory, I tried the following code, but not work
if ($adldap->authenticate($username, $password)){
$result=$adldap->user()->infoCollection("*")->displayName; //show all record
print_r($result);
}
any idea, thank you very much
You'd need a search to gather all of the users -- see https://github.com/adldap/adLDAP/blob/master/docs/SEARCH-FUNCTIONS.md for documentation. Depending on how many records are in your AD, you probably want to use a paged query. See https://github.com/adldap/adLDAP/blob/master/docs/SEARCH-FUNCTIONS.md#paginate for info there.
Once you have a result set, iterate over the result set and get each user's display name:
foreach($results as $result){
echo $result['displayName'];
}