need script for smbldap-useradd/setquota/ldapadd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need script for smbldap-useradd/setquota/ldapadd
# 1  
Old 08-17-2010
need script for smbldap-useradd/setquota/ldapadd

Hello guys,

I am trying to add users to samba/ldap system, set their quota, set them a common password and add auto_home records for the new users

User list file is in below format

Code:
Firstname Lastname Username

Command I run to add user is

Code:
smbldap-useradd -a -m -N $Firstname -S $Lastname $USERNAME

Password is set using
Code:
smbldap-passwd $USERNAME

Currently I have below working only to set passwords.
Code:
#!/bin/bash

ChangePasswd()
{
/usr/bin/expect <<EOF
spawn smbldap-passwd $user
expect "New password: "
send -- "$2\r"
expect "Retype new password: "
send -- "$2\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user $1
fi
done < usernames

./changepassword <common password>

Then I'd like to set quota to 100MB,

Code:
setquota -u $USERNAME 0 100000 0 0 /

Finally, I want to add auto_home records for all users,

Code:
ldapadd -v -x -D 'cn=admin,dc=blah' -w <admin password> -f /tmp/temp.$USER.ldif

cat > /tmp/temp.$USER.ldif <<EOF
dn: cn=$USER,ou=auto_home,dc=blah
objectClass: automount
automountInformation: -rw,hard,intr <IPOFNFSSERVER>:/export/$USER
cn: $USER
EOF

I'd like to have the script remove /tmp/temp.$USER.ldif after done.

Can anyone help me to combine all in a single bash script. This is going to be used on an ubuntu system.

Thanks much!
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Useradd script

Trying to create a bash script that will read the /etc/passwd file for existing UID's before adding a new user and also does an incremental by allocating the next available UID.And also add the user to the correct group.Please help I am a newbie in scripting. (2 Replies)
Discussion started by: tshepang
2 Replies

2. Solaris

useradd

I want to creat a 27 logins in solaris.Can anyone tell me how to write a script for that so that i create at a time for all 27 people. Thanks to guide me. (6 Replies)
Discussion started by: kkalyan
6 Replies

3. UNIX for Dummies Questions & Answers

how to use ldapadd

We have netgroup in ldap in Sun java directory server, how can I add or remove a user to/from a netgroup via command line without using ldif file? I need to put this into a script. Here is a sample netgroup, and I want to add user tonyz to it: # ldapsearch -h ldapserver.com -p 389 -b ... (1 Reply)
Discussion started by: jalite19
1 Replies

4. Solaris

useradd

if useradd command is deleted in solaris how do we add user (3 Replies)
Discussion started by: vivek_ng
3 Replies

5. Shell Programming and Scripting

trouble making a useradd script

i'm new to scripting in unix and am trying to make a script to add a user and an encrypted password for them. this is what i have and it isn't giving me any errors, but when i try to login with the new user, the password doesn't work. i'm hoping someone can point me in the right direction ... (1 Reply)
Discussion started by: patt4179
1 Replies

6. Shell Programming and Scripting

Help with useradd script

Ok Im trying too make this shell script create users from my text file, I also want to type in a password for the new users. So thay can make a uniq one themself after first logon. #!/bin/sh # Sebastian schmidt clear echo "*************************************************************"... (3 Replies)
Discussion started by: chipmunken
3 Replies

7. Shell Programming and Scripting

useradd -c in a script????

Here's my box info: ROOT@fcivra: uname -a SunOS fcivra 5.6 Generic_105181-26 sun4m sparc SUNW,SPARCstation-5 I am creating a script called adduser, that will incorporate the useradd command. Here is what it looks like: #!/bin/sh echo "Enter the person's VZID (lower case): \c" read VZID... (2 Replies)
Discussion started by: cdunavent
2 Replies

8. UNIX for Dummies Questions & Answers

useradd script

I have a txt file with many users and I need to add them and create random passwords. Does any one have a script in pearl possible? (3 Replies)
Discussion started by: macdonto
3 Replies
Login or Register to Ask a Question