Search code examples
phpactive-directoryldapadldap

Load users from Active Directory using ADLDAP


I'm using the ADLDAP library (http://adldap.sourceforge.net) to interact with Active Directory. I am using PHP. I would like to get all users from Active Directory and save them to array. Is there any way to do this?


Solution

  • You probably want to do something like:

    $adldap = new adLDAP();
    $usernames = $adldap->user()->all();
    
    $users = array();
    foreach ($usernames as $username)
    {
        $userInfo = $adldap->user()->infoCollection($username);
        $users[$username] = $userInfo;
    }
    

    the all() method is doumented here.