Skip to content

Instantly share code, notes, and snippets.

@blaxter
Forked from javierag/create-users.pl
Created February 2, 2015 18:00
Show Gist options
  • Save blaxter/267cb2b9bdcb164c2815 to your computer and use it in GitHub Desktop.
Save blaxter/267cb2b9bdcb164c2815 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# Copyright (C) 2014 Zentyal S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use strict;
use warnings;
use EBox;
use EBox::Global;
use EBox::Samba::User;
my ($max, $min);
if (not @ARGV) {
die "Usage: $0 minNumericPostfix maxNumericPostix";
} elsif (@ARGV == 1) {
($max) = @ARGV;
$min = 1;
} else {
($min, $max) = @ARGV;
}
EBox::init();
my $samba = EBox::Global->modInstance('samba');
my $parent = EBox::Samba::User->defaultContainer();
for my $i ($min .. $max) {
my $username = "u$i";
my $password = 'a';
my $user = EBox::Samba::User->create(
samAccountName => $username,
parent => $parent,
givenName => $username,
sn => $username,
displayName => $username,
password => $password,
);
}
print "First user created u$min\n";
print "Last user created u$max\n";
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment