-
Notifications
You must be signed in to change notification settings - Fork 0
/
genUsers.pl
77 lines (60 loc) · 2.11 KB
/
genUsers.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
#-----------------------------------------------------------------
# Alcatel - Alcatel-Lucent(Schweiz)AG, Friesenberg Strasse 75
#-----------------------------------------------------------------
#
# genUsers.pl: Generate a set of users account complete with password, and an
# import file for PasswordSafe for a given list of users accounts (passed in
# a text file)
#
# Project:
# Author: Farley Balasuriya, ([email protected])
# Created: Sat Feb 10 04:10:25 2007
# History:
# v0.2 -
# v0.1 - 10/02/07 - initial version created
#
#-----------------------------------------------------------------
$svn_rev = '$Rev: 110 $';
$svn_id = '$Id: tapp.pl 110 2005-04-25 02:40:51Z farley $';
$svn_LastChangedDate =
'$LastChangedDate: 2005-04-25 04:40:51 +0200 (Mon, 25 Apr 2005) $';
#-----------------------------------------------------------------
#-----------------------------------------------------------------
use strict;
use warnings;
use Getopt::Long;
use Time::Piece;
my (@batch, @psafe, @csv, $t, $str);
#default SA (Service Account) extension
# my $user_account_prefix = "QSSA_";
# my $user_account_prefix = "SA_";
my $user_account_prefix = "";
#generate the password safe date string
$t = localtime;
$str = $t->ymd("/") . " " . $t->hms;
while (<>) {
chomp();
my $account = $user_account_prefix . $_;
my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ ^ - + _ [ ] ) );
my $password = join( "", @chars[ map { rand @chars } ( 1 .. 10 ) ] );
#generate accounts for batch file
push @batch, "net user $user_account_prefix$_ $password /Add \n";
# generate PasswordSafe import file for documentation
push @psafe, "_Import.$account,$account,$password,,,$str,,,,,,\n";
# csv file
push @csv, "$account;$password\n";
}
# print out the batch
print "\@echo off\n:: Create user accounts\n";
print @batch;
print "goto END\n";
print "\n\n\n";
# print out the Password safe import file
print ":: - Password safe import file\n";
print @psafe;
print "\n\n\n";
# print out a CSV format to hand out to people
print ":: - CSV format if you want it...\n";
print @csv;
print "\n\n\n:END\n";