gnumoksha / php-freeipa

FreeIPA SDK for PHP
GNU Lesser General Public License v3.0
19 stars 19 forks source link

Is it possible to get all users? #10

Closed Lormen closed 5 years ago

Lormen commented 5 years ago

Hi, would it be possible to pull all users as I was planning on filling a table for user editing?

Cheers,

Pete

gnumoksha commented 5 years ago

Hi. You can use $ipa->user()->find() without arguments.

Here is a snippet showing how to export users information to CSV.

$fp = fopen('users.csv', 'wb');
$users = $ipa->user()->find();
foreach ($users as $user) {
    $fields = [
        $user->cn[0],
        $user->gecos[0],
        $user->homedirectory[0],
        $user->krbprincipalname[0],
        $user->loginshell[0],
        implode(', ', $user->memberof_group),
        $user->dn,
    ];
    fputcsv($fp, $fields);
}
fclose($fp);
gnumoksha commented 5 years ago

Hi. I'm going to close this issue as I think I've answered it by email. Feel free to open a new issue if you need help.