Add System User
Server Training - Server Management

 At times you will be adding LDAP to an existing server that has users already created.  This script will help you add those users to your LDAP directory.  Be sure to verify that the users were created correctly once it is complete.

Lesson 6 / Lesson 8


Add System User with a Script
Note you will need to change the script for your domain and administrator.

grep $1 /etc/passwd > /tmp/changeldappasswd.tmp

/usr/share/openldap/migration/ \
    /tmp/changeldappasswd.tmp /tmp/changeldappasswd.ldif.tmp

cat /tmp/changeldappasswd.ldif.tmp | sed s/padl/example/ \
    > /tmp/changeldappasswd.ldif

ldapadd -x -D "cn=admin,dc=linuxt,dc=local" -W -f \

rm -f /tmp/changeldappasswd.*

You will be prompted for the password to create for the user.

Then to verify you can search the database for information on the user you added.
ldapsearch -x -b "dc=linuxt,dc=local" "(objectclass=*)"

# sue, People,
dn: uid=sue,ou=People,dc=linuxt,dc=local
uid: sue
cn: sue
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSEh
shadowLastChange: 14407
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 504
gidNumber: 504
homeDirectory: /home/sue


Copyright by CyberMontana Inc.
Cannot be reproduced without written permission.  Box 1262 Trout Creek, MT 59874