[Perl] Zentyal LDAP Passwords change

This is a small script I have done today in Zentyal that allows you to change the passwords of all users in LDAP. It creates a file /tmp/usuarios.csv with the users and their new passwords

use strict;
use warnings;
use EBox;
use EBox::UsersAndGroups;
use EBox::Global;
use EBox::Util::Random;

my $salida ="/tmp/users.csv";
open (OUT,">$out") || 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";
  close (OUT); 

Deja un comentario