Last active
August 29, 2015 14:14
-
-
Save javierag/8c13a2673dd1323a69d7 to your computer and use it in GitHub Desktop.
Create uses for Zentyal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'; | |
my $nFill = 4 - length($i); | |
if ($nFill > 0) { | |
$username .= '0' x $nFill; | |
} | |
$username .= $i; | |
my $password = 'a'; | |
my $user = EBox::Samba::User->create( | |
samAccountName => $username, | |
parent => $parent, | |
givenName => $username, | |
sn => $username, | |
displayName => $username, | |
password => $password, | |
); | |
print "$username created\n"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment