Friday, 23 October 2015

CentOS Directory Server (LDAP) : Useful commands.

How to add a new ldap user?


create a ldif (newuser.ldif) file with the content :
         dn: uid=first.last,ou=People,dc=example,dc=com
         uid: first.last
         cn: First Last
         sn: Last
         objectClass: account
         objectClass: posixAccount
         objectClass: person
         objectClass: top
         userPassword: XXXXXXXX
         loginShell: /bin/bash
         uidNumber: XXXX
         gidNumber: XXX
         homeDirectory: /home/first.last
         gecos: first last

Add the ldif to LDAP
ldapadd -Wxc -D "cn=Directory Manager" -H ldap://localhost:389 -f newuser.ldif

This will prompt you for the Directory Manager's password.

How does an Administrator change a password from the command-line?

ldappasswd -Z -h hostname -p 389 -D "cn=Directory Manager" -w admin_password -s new_password "uid=first.last,ou=People,dc=example,dc=com"

How to Remove a User from an Existing group ?

ldapmodify -x -h hostname -p 389 -D "cn=Directory Manager" -w password
dn: cn=group_name,ou=Group,dc=example,dc=com
changetype: modify
delete: memberUid
memberUid: first.last
^d
Response :
modifying entry "cn=group_name,ou=Group,dc=example,dc=com

How to Add a User to a Existing group ?


ldapmodify -x -h hostname -p 389 -D "cn=Directory Manager" -w password
dn: cn=group_name,ou=Group,dc=example,dc=com
changetype:modify
add: memberUid
memberUid: first.last
^d
Response:
modifying entry "cn=group_name,ou=Group,dc=example,dc=com"

No comments:

Post a Comment