Bulk LDAP Password Change
From Zentyal Linux Small Business Server
This HOWTO is intended to show you how to change all your LDAP users' passwords in a row:
Put the following script in a text file called passwordchange.pl and make it executable for root. Afterwards just execute it issueing:
sudo perl passwordchange.pl
It will change your LDAP users passwords and create a file in /tmp/users.csv, with the list of users and their passwords.
For Zentyal 3.0
#perl #!/usr/bin/perl use strict; use warnings; use EBox; use EBox::UsersAndGroups; use EBox::Global; use EBox::Util::Random; EBox::init(); my $out ="/tmp/users.csv"; {| border=1 class="simple" ! die "ERROR: Can't create or write to file $out\n"; |} my $users = EBox::Global->modInstance('users'); my @userlist = @{$users->users() } ; foreach my $user (@userlist) { my $password; $password = EBox::Util::Random::generate(8); print OUT $user->name()." ". $password."\n"; $user->changePassword($password,0) } close (OUT);