LDAP administration commands

To add a user create an ldif file as below
[root@host1 sherlock]# cat sherlock.ldif

dn: uid=sherlock,ou=People,dc=test,dc=domain,dc=com

uid: sherlock

cn: sherlock

objectClass: account

objectClass: posixAccount

objectClass: top

objectClass: shadowAccount

shadowMin: 0

shadowMax: 99999

shadowWarning: 7

loginShell: /bin/bash

uidNumber: 2016

gidNumber: 2016

homeDirectory: /home/sherlock

gecos: Holmes Shelrock

shadowLastChange: 16610

userPassword: {SSHA}gqTy2GiM0mLO3rNuLfrHJHZaOD7/6TOk


Use the below command for SSHA password generation 

 #slappasswd -h {SSHA} -s password

Add the user with 

 #ldapadd  -H ldaps://host.test.domain.com -D uid=sherlock,ou=People,dc=test,dc=domain,dc=com” -W -f sherlock.ldif

 To delete the ldapuser 


#ldapdelete  -H ldaps://host.test.domain.com -D uid=sherlock,ou=People,dc=test,dc=domain,dc=com -W “uid=anoopk,ou=People,dc=test,dc=domain,dc=com”


To search a user

#ldapsearch -H ldaps://test.dev.cluster.host.com -D uid=anoopk,ou=people,dc=dev,dc=cluster,dc=host,dc=com -W |grep -i -20 Holmes

To change password of user sherlock

#ldappasswd -H test.dev.cluster.host.com -D uid=anoopk,ou=people,dc=dev,dc=cluster,dc=host,dc=com -W -S “uid=sherlock,ou=people,dc=dev,dc=cluster,dc=host,dc=com”


#ldappasswd -D uid=anoopkum,ou=people,dc=dlx,dc=idc,dc=ge,dc=com -W -s rajesh@123 uid=sherlock,ou=people,dc=dev,dc=cluster,dc=host,dc=com






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s