Peter Estephan
Peter Estephan

Reputation: 13

AD LDAP - How to list all users within a Group

Im currenlty using the following ADLDAP repository: http://adldap.sourceforge.net/

On a page I am just currently trying to achieve: taking a list of users in a certain AD Group and put it into a dropdown for me to select in HTML. Right now I have this and I have not yet got it to show any users in the group yet:

include (dirname(__FILE__) . "/../src/adLDAP.php");
    try {
        $adldap = new adLDAP();
    }
    catch (adLDAPException $e) {
        echo $e; 
        exit();   
    }

    $users = $adldap->group()->members('Group_X');
    echo $users;

Could someone please help me and guide me in the right direction to pull a list of users from a group in AD and make it be able to be used in a dropdown menu.

Upvotes: 1

Views: 1293

Answers (1)

Steve Bauman
Steve Bauman

Reputation: 8668

If you use Adldap2 you could do this:

$group = $adldap->search()->groups()->find('Accounting');

$users = $group->getMembers();

foreach ($users as $user) {

    echo $user->getCommonName();    

}

Upvotes: 2

Related Questions