Monday, March 19, 2012

open ldap commands

apt-get install ldap-account-manager ldap-auth-config ldapscripts slapd ldap-utils migrationtools.

1) Create a file with ldif extension (userinfo.ldif)

dn: uid=user,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: userid
sn: Doe
givenName: User
cn: User
displayName: John Doe
uidNumber: 1000
gidNumber: 10000
userPassword: user123
gecos: John Doe
loginShell: /bin/bash
homeDirectory: /home/john
shadowExpire: -1
shadowFlag: 0
shadowWarning: 7
shadowMin: 8
shadowMax: 999999
shadowLastChange: 10877
mail: rupesh123@example.com
postalCode: 31000
l: Toulouse
o: Example
mobile: +91 1234567890
homePhone: +33 (0)40 35963258
title: System Administrator
postalAddress:
initials: JD

2) Add User to openLDAP.

sudo ldapadd -x -D cn=admin,dc=example,dc=com -W -f userinfo.ldif

3) Search User:

ldapsearch -xLLL -b "dc=example,dc=com"
a) Displays the whole data of all the user in "dc=example,dc=com".

ldapsearch -xLLL -b "dc=example,dc=com" uid=user
b) Displays comple info of User whose uid=use.




ldapsearch -xLLL -b "dc=example,dc=com" uid
c) Displays the dn of all the users in "dc=example,dc=com"

 4) If you make a mistake when entering your information you can execute the dialog again using:
sudo dpkg-reconfigure ldap-auth-config 
 
The results of the dialog can be seen in /etc/ldap.conf 
 
5) Change User Password:
 
sudo apt-get install ldapscripts

Next, edit the config file /etc/ldapscripts/ldapscripts.conf uncommenting and changing the following to match your environment:

SERVER=localhost
BINDDN='cn=admin,dc=example,dc=com'
BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd" SUFFIX='dc=example,dc=com'
GSUFFIX='ou=Groups'
USUFFIX='ou=People'
MSUFFIX='ou=Computers'
GIDSTART=10000
UIDSTART=10000
MIDSTART=10000

Now, create the ldapscripts.passwd file to allow authenticated access to the directory:
sudo sh -c "echo -n 'secret' > /etc/ldapscripts/ldapscripts.passwd" sudo chmod 400 /etc/ldapscripts/ldapscripts.passwd


Replace secret with the actual password for your LDAP admin user.

The ldapscripts are now ready to help manage your directory. The following are some examples of how to use the scripts.
  • Change a user's password:
    sudo ldapsetpasswd userid
    Changing password for user uid=userid,ou=People,dc=example,dc=com
    New Password: 
    New Password (verify): 
    
 

https://help.ubuntu.com/11.04/serverguide/C/openldap-server.html