Saturday, August 3, 2013

LDAP Command Examples


Following ldap command examples can be useful for Database Administrators, especially when working on the middletier.. I used these types of command to export/import the user information from Microsoft's Active Directory to Oracle 's Internet Directory.

*To Export all the user information (with all attributes) from a ldap directory

ldapsearch -p ldap_port -h  ldap_host -D "cn=adminuser" -w adminpasswd -L -s one -b "cn=Users,dc=company,dc=com" "(cn=*)" > users.ldif

*To Export all the user information (specifying attributes) from a ldap directory
ldapsearch -p ldap_port -h  ldap_host -D "cn=adminuser" -w adminpasswd -L -s one -b "cn=Users,dc=company,dc=com" "(cn=*)" attribute1 attribute2 attribute3 > users.ldif

*To Export a single user from an ldap directory (with all attributes)
ldapsearch -p ldap_port -h  ldap_host -D "cn=adminuser" -w admipasswd -L -s one -b "cn=Users,dc=company,dc=com" "(cn=user_you_want_to_export)"  > user.ldiff

*To Export a single user from an ldap director 

ldapsearch -p ldap_port -h  ldap_host -D "cn=adminuser" -w adminpasswd -L -s one -b "cn=Users,dc=company,dc=com" "(cn=user_you_want_to_export)" attribute1 attribute2 attribute3  > user.ldiff

*To Import an ldiff export file
ldapadd -h ldap_host -p ldap_port -D "cn=adminuser" -w adminpasswd -c -v -f /home/appoid/ldiff_file.ldiff

*To check a user/password /ldapbind
ldapbind -h LDAP_HOST_IP -p LDAPHOST_PORT -D"CN=Erman,OU=OU_erptemp,OU=OU_Users,DC=testdom,DC=com" -w"password_of_erman"

2 comments :

  1. Excellent help, Erman. Thanks a lot. As an administrator I found these LDAP examples very useful.

    Regards,
    Silvester Norman
    Change MAC Address

    ReplyDelete
    Replies
    1. thank you for your interest Silvester.
      I used these commands in an OID project. They were handy for migrating the user information.

      Delete

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.