# pdadmin script

**URL:** <https://community.unix.com/t/pdadmin-script/242314>\
**Category:** Shell Programming and Scripting\
**Created:** [June 11, 2009, 11:53am UTC](https://community.unix.com/t/pdadmin-script/242314 "2009-06-11T11:53:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sophos](https://community.unix.com/letter_avatar/sophos/32/6_449c533f586939b6e5f246632a46421f.png) [@sophos](https://community.unix.com/u/sophos)\
**Post date:** [June 11, 2009, 11:53am UTC](https://community.unix.com/t/pdadmin-script/242314/1 "2009-06-11T11:53:00Z")

</div>

Hello all,

I would need a scirpt to perform the following operation:

1. I would like to give a spreadsheet as input with 3 columns with firstname,lastname,userid in order
2. 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.

---

<div class="post-metadata">

**Author:** ![sweetblood](https://community.unix.com/letter_avatar/sweetblood/32/6_449c533f586939b6e5f246632a46421f.png) [@sweetblood](https://community.unix.com/u/sweetblood)\
**Post date:** [June 11, 2009, 12:20pm UTC](https://community.unix.com/t/pdadmin-script/242314/2 "2009-06-11T12:20:26Z")

</div>

geewiz ~~ I would like a pony

This is not a free script writing site "come and get you dreams filled." What have you done to make this script happen?

---

<div class="post-metadata">

**Author:** ![sophos](https://community.unix.com/letter_avatar/sophos/32/6_449c533f586939b6e5f246632a46421f.png) [@sophos](https://community.unix.com/u/sophos)\
**Post date:** [June 11, 2009, 1:09pm UTC](https://community.unix.com/t/pdadmin-script/242314/3 "2009-06-11T13:09:55Z")

</div>

i have tried a bit as follows but wondering if there is a easier way:

#!/usr/bin/perl

#Clears Screen  
$CLEAR=`clearscreen`;  
print $CLEAR;

#Set LDAPDomain  
$DOMAIN="ou=people,o=xxxxxx,c=us";

# 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`;
