I would need a scirpt to perform the following operation:
I would like to give a spreadsheet as input with 3 columns with firstname,lastname,userid in order
The script should read from the spreadsheet and search if each user exists in particular groups "Group1" by using the command user show-groups userx and grep for group group1.If user has group1 then continue with the following commands :
pdadmin -a sec_master -p XXXXX user modify userx password passwordx
pdadmin -a sec_master -p XXXXX user modify userx password-valid no
or
If the user doesnt belong to the group group1 then do the following commands:
pdadmin -a sec_master -p XXXXX group modify group1 add userx
pdadmin -a sec_master -p XXXXX user modify userx account-valid yes
pdadmin -a sec_master -p XXXXX user modify userx password passwordx
pdadmin -a sec_master -p XXXXX user modify userx password-valid no
The values of XXXXX,group1,passwordx should be requested when the script is run.
# Collect user name
print "Please enter user file >>";
$FILE=<STDIN>;
chomp($FILE);
#print "Please enter the user's First Name>>";
#$FNAME=<STDIN>; #chomp($FNAME); #print "Please enter the user's Last Name>>";
#$LNAME=<STDIN>; #chomp($LNAME);
# Collect Groups
print "Please enter groups to add user too, Seperated by a comma(,)>>";
#$GROUPS=<STDIN>; #chomp($GROUPS);
#@GROUPLIST=split(/,/,$GROUPS);
#$USERNAME=~s/\n//;
#$GROUPLISTCOUNT=scalar(@GROUPLIST); #print $GROUPLISTCOUNT;
#Collect Admin Username
$SEC_USER=<STDIN>;
chomp($SEC_USER);
#$SEC_USER=~s/\n//;
$COMMAND4=`pdadmin -a $SEC_USER -p $SEC_PASS user create $USERNAME cn=$USERNAME,
$DOMAIN $FNAME $LNAME $PASS_RESET`;
$COMMAND5=`pdadmin -a $SEC_USER -p $SEC_PASS user modify $USERNAME account-valid
yes`;
$COMMAND6=`pdadmin -a $SEC_USER -p $SEC_PASS user modify $USERNAME password-vali
d yes`;