Welcome!

Open Source Authors: Liz McMillan, Maureen O'Gara, Jeremy Geelan, Reuven Cohen, Lavenya Dilip

Related Topics: Open Source

Open Source: Article

How to Create a Directory Service Using the OpenLDAP Directory Server

A directory service is an application that stores, retrieves, and modifies information about network resources

A new directory entry gets added. A directory entry can also be modified. For example, modify the title in the previously added entry. The directory modifications are specified in an LDIF file as shown in Listing 3.

Listing 3. modifyEntry.ldif
dn: cn=Deepak Vohra,ou=jdeveloper,dc=example,dc=com
changetype: modify
replace: title
title: Oracle DBA

Run the ldapmodify command as shown below.

ldapmodify -D "cn=Manager,dc=example,dc=com" -w openldap -a -f modifyEntry.ldif

The directory entry gets modified.

Next, delete a directory entry. As an example, delete the entry that was added with ldapmodify. Specify the DN of the entry to delete an LDIF file as shown in Listing 4. The delete operation is specified with changetype:delete.

Listing 4 deleteEntry.ldif
dn: cn=Deepak Vohra,ou=jdeveloper,dc=example,dc=com
changetype: delete

Run the ldapmodify command as shown below:

ldapmodify -D "cn=Manager,dc=example,dc=com" -w openldap -f deleteEntry.ldif

The directory entry gets deleted.

Deleting a Directory
The ldapdelete tool is used to delete directory entries. The DNs for the entries to delete can be specified on the command line or in an LDIF file. As an example delete the directory entry for DN "ou=jdevloper,dc=example,dc=com." To delete recursively specify the -r option. The ldapdelete command to delete a directory entry by authenticating to the directory is shown below:

>ldapdelete -D "cn=Manager,dc=example,dc=com" -r -v -w openldap "ou=jdeveloper,dc=example,dc=com"

Non-leaf entries don't get deleted with the ldapdelete tool.

Conclusion
The OpenLDAP LDAP server provides a directory service to store and modify information about network resources in a directory that's stored in the Berkeley DB.

More Stories By Deepak Vohra

Deepak Vohra is a Sun Certified Java 1.4 Programmer and a Web developer.

More Stories By Ajay Vohra

Ajay Vohra is a senior solutions architect with DataSynapse Inc.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
karan 02/20/08 12:18:02 AM EST

hi acn i know hoe to create directory structure for
dn: uid: karan.sngl@gmail.com,dc=mail,dc=xyz,dc=de.

and our suffix is dc=mail,dc=xyz,dc=de.

Do reply me at karan.sngl@gmail.com
please help me out i m getting so much problem in creating directory scructure

Tom Britton 07/12/07 04:57:45 PM EDT

LDAP is an overly complex, arcane system for storing and retrieving informtion, some of which can be used for authentication. This article may be useful for extending the authors' list of publications but does little to help explain or demystify LDAP, OpenLdap, or anything else. It uses jargon with abandon, and where some of the jargon is defined, it provides no explanation, providing no understanding. As a cookbook, its recipes are too terse to be useful. Of course in a magazine article, space is at a premium, but the authors have used their allocation very poorly. A waste of time and print space.