What is Apache Directory Studio?
The Eclipse based LDAP browser and directory clientWhat is LDAP?
Apache Directory Studio is a complete directory tooling platform intended to be used with any LDAP server however it is particularly designed for use with ApacheDS. It is an Eclipse RCP application, composed of several Eclipse (OSGi) plugins, that can be easily upgraded with additional ones. These plugins can even run within Eclipse itself.
Source: http://directory.apache.org/studio/
The Lightweight Directory Access Protocol (LDAP) is an application protocol for reading and editing directories over an IP network. A directory is an organized set of records. For example, the telephone directory is an alphabetical list of persons and organizations, with each record having an address and phone number. A directory information tree often follows political, geographic, or organizational boundaries. LDAP directories often use Domain Name System (DNS) names for the highest levels. Deeper inside the directory might appear entries for people, departments, teams, printers, and documents.If this is your first time to LDAP, you might be wondering how is this different from an RDBMS. I suggest my readers to visit the following article Should I Use a Directory, a Database, or Both?
Source: http://en.wikipedia.org/wiki/LDAP
A Brief Background
We have a small startup company named Mojo Enterprises. We have four people, and two of them are admins. Our task is to create a hierarchical structure of our organization using LDAP because we anticipate the eventual growth of the company. We may have hundreds of people from different departments in five years time. Each has their own information and structure. These information and structure will be shared among different applications of the company. LDAP is a good protocol to meet all these requirements.
Layout the Structure
Let's define the important elements of the company.
Company Name: Mojo Enterprises
Members:
- Hugo Williams
- John Keats
- John Milton
- Robert Browning
- Hugo Williams
- John Keats
We need to assign the topmost parent of our structure. Logically, the name of the company fits that requirement. We'll pick the name mojo as the topmost parent.
Under the mojo we will assign our members. There are many ways to organize our members. We can organize them by gender, by job function, and etc. For this tutorial we'll organize them based on identity and roles. We'll put all the identities of each person in a separate element, while the roles will be placed on another element.
Under the roles we have two sub-divisions. Remember we have the regular users and the admins. What we'll do is divide the roles into elements.
Here's how our structure would like:
mojo
|
|--roles
| |
| |--admin
| |--regular
|
|--identities
|
|--guy1
|--guy2
|--guy3
|--guy4
We'll make the names a little bit formal, and make it conform with the naming convention of LDAP. For the topmost parent, we'll retain mojo. For roles, we'll use groups instead. For identities, we'll use usersWhen we're done with this tutorial, we should have the following structure:
It's really simple to do. All you need is an Apache Directory Studio, this tutorial, and patience.
Install the Apache Directory Studio
Before we can do any LDAP-related work, we need to have an IDE first. Although it's not required, we'll require it for this tutorial. And why not? It's free anyway.
To install the Apache Directory Studio, visit the following link http://directory.apache.org/studio/downloads.html Follow the instructions on that link
for the installation steps.
Create a New Server
Once you have installed the studio, we need to create a server. Here are the steps:
1. Open Apache Directory Studio.
3. Go to File, and click New. A popup window will open.
4. Expand the Apache DS folder, and select the Apache DS Server
5. Click Next.
6. Type-in any name for the server. For example, apache-ds-server
7. Click Finish.
8. A new server has been added on your Servers panel.
If you can't see the Servers panel, go the menu bar then click Window > Show View > Apache DS > Servers
9. Select your server, then click the Run button.
Your server should now be running.
Create a Connection
To browse the contents of the server, we need to create a connection. Here are the steps:
1. Right-click on your server.
2. Select LDAP Browser
3. Select Create a Connection. An alert message will popup indicating the a new connection has been created.
4. Go to the Connections panel.
If you can't see the Connections panel, go the menu bar then click Window > Show View > LDAP Browser > Connections
5. Double-click the name of the new connection you've created earlier.
6. The LDAP Browser panel should refresh and show the contents of the server.
Notice the topmost entry of this server is DIT, followed by the Root DSE.
7. Expand the Root DSE folder. There are two sub-entries: ou=schema and ou=system.
These are partitions in the server. Do not modify them unless you know what you're doing.
Create a New Partition
To add our company to the root tree, we need to create a new partition. Everything related to the company will be attached to this new partition. Here are the steps:
1. Go to the Servers panel, and right-click your server.
2. Select Open Configuration. A server.xml editor will appear on the main panel.
3. At the bottom part of server.xml, there are five tabs. Click the Partitions tab.
The Partitions tab should appear.
4. Click on Add and enter the following details for this new partition.
ID: mojo
Cache Size: 100
Suffix: o=mojo
5. Save your changes (CTRL + S). A new partition has been added.
6. Restart your Apache DS server.
7. Refresh the LDAP Browser panel.
8. Click on the Root DSE folder. A new editor will open containing the details of this folder.
Notice the namingContexts attribute. The namingContexts o=mojo shows in the lists. However it doesn't show under the Root DSE tree because we need to add the organization manually in the tree.
Add the Parent Organization
Our company is an organization. In LDAP, to represent a company we use the organization object which is represented by the alias o. So if our company's name is mojo, the Distinguished Name (dn) of the company is o=mojo. It's a naming convention. (The Distinguished Name is like the primary key or primary identity).
To create the organization object, follow the steps below:
1. Right-click on the Root DSE folder. Select New. Select New Context Entry
2. Select Create entry from scratch. Click Next. The Object classes window will appear.
3. Find the organization object. Select it then click Add
4. Click Next. Now you need to enter a Distinguished Name (dn). Click on the pulldown menu. Select o=mojo.
5. Click Next. The Attributes window will appear. Examine the values.
6. Click Finish. Notice the new partition now appears under the Root DSE.
Add the Organizational Units
Earlier we mentioned we'll structure our company based on users (contains personal information of the user) and groups (contains the authorization level of each person).
Both of these represent an organizational unit.
In LDAP, to represent an organizational unit we use the organizationalUnit object which is represented by the alias ou. So if we have a unit name users, the Distinguished Name (dn) is ou=users,o=mojo. Why is there an o=mojo? It's a naming convention. The same convention applies to groups. The Distinguished Name (dn) is ou=users,o=mojo. This can be likened the way we name URLS. For example, users.mojo.com or groups.mojo.com.
We'll add first the users unit. Here are the steps:
1. Go to the LDAP Browser panel. Expand the Root DSE folder.
2. Right-click the o=mojo entry. Select New. Select New Entry.
The Entry Creation Method window will appear.
3. Select Create entry from scratch. Click Next. The Object Classes window will appear.
4. Find the organizationalUnit object. Select it then click Add.
5. Click Next. Now you need to enter a Distinguished Name (dn).
The Parent field should read o=mojo.
On the RDN field enter ou. On the value field enter users. The DN Preview should read ou=users,o=mojo
6. Click Next. The Attributes window will appear. Examine the values.
7. Click Finish. We've just created the ou=users organizational unit.
Add the Second Organizational Units
We've just added the ou=users organizational unit. We need to add the organizational unit for groups as well. We'll follow the same steps.
1. Go to the LDAP Browser panel. Expand the Root DSE folder.
2. Right-click the o=mojo entry. Select New. Select New Entry.
The Entry Creation Method window will appear.
3. Select Create entry from scratch. Click Next. The Object Classes window will appear.
4. Find the organizationalUnit object. Select it then click Add.
5. Click Next. Now you need to enter a Distinguished Name (dn).
The Parent field should read o=mojo.
On the RDN field enter ou. On the value field enter groups. The DN Preview should read ou=groups,o=mojo
6. Click Next. The Attributes window will appear. Examine the values.
7. Click Finish. We've just created the ou=groups organizational unit.
Add the Staff
Now we need to add our four people:
- Hugo Williams
- John Keats
- John Milton
- Robert Browning
- Hugo Williams
- John Keats
Let's start with the ou=users. We'll be adding four persons. We'll represent each person using the inetOrgPerson object.
What's an inetOrgPerson object?
The inetOrgPerson object class is a general purpose object class thatAn inetOrgPerson can contain a user id (uid) and password (userPassword) which will be useful later for authenticating users from using LDAP.
holds attributes about people. The attributes it holds were chosen
to accommodate information requirements found in typical Internet and
Intranet directory service deployments.
Source: http://www.faqs.org/rfcs/rfc2798.html
Here are the steps we need to do:
1. Go to the LDAP Browser panel. Expand the Root DSE folder.
2. Expand the o=mojo entry.
3. Right-click the ou=users entry. Select New. Select New Entry.
The Entry Creation Method window will appear.
4. Select Create entry from scratch. Click Next. The Object Classes window will appear.
5. Find inetOrgPerson object. Select it then click Add.
6. Click Next. Now you need to enter a Distinguished Name (dn).
The Parent field should read ou=users,o=mojo.
On the RDN field enter cn. On the value field enter Hugo Williams.
The DN Preview should read cn=Hugo Williams,ou=users,o=mojo (cn represent Common Name).
7. Click Next. The Attributes window will appear. Examine the values.
8. Under the sn attribute, enter Williams (sn stands for Surname)
9. We need to add a username for this user. Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
10. On the Attribute type field, enter uid. This will serve as the username of the person.
11. Click Next, then click Finish.
12. You're back on the Attributes window. On the uid attribute value, enter hwilliams
13. We need to add a password for this user. Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
14. On the Attribute type field, enter userPassword. This will serve as the password of the person.
15. Click Next, then click Finish.
16. You will be asked to enter a password. Enter pass as the new password. Make sure that the Select Hash Method is set to Plaintext
17. Click OK.
A new entry has been added under the ou=users. The new entry is cn=Hugo Williams.
Now we need to add the remaining three users. In order to do that, just repeat the same steps earlier. Here are the details of the three remaining users.
Name: John Keats uid: jkeats userPassword: pass Name: John Milton uid: jmilton userPassword: pass Name: Robert Browning uid: rbrowning userPassword: passAdd the Authorization Levels
We have added the personal information, as well as the usernames and passwords, for each person under the ou=users. Now, we will be adding the authorization level for each of these persons.
We'll add them under ou=groups. We'll use the groupOfUniqueNames object to represent each role.
Let's add the User role first.
1. Go to the LDAP Browser panel. Expand the Root DSE folder.
2. Expand the o=mojo entry.
3. Right-click the ou=groups entry. Select New. Select New Entry.
The Entry Creation Method window will appear.
4. Select Create entry from scratch. Click Next. The Object Classes window will appear.
5. Find the groupOfUniqueNames object. Select it then click Add.
6. Click Next. Now you need to enter a Distinguished Name (dn).
The Parent field should read ou=groups,o=mojo.
On the RDN field enter cn. On the value field enter User
The DN Preview should read cn=User,ou=groups,o=mojo
8. Click Next. The Attributes window will appear. Examine the values.
Notice there's a uniqueMember attribute. We'll be placing the Distinguished Name (dn) of our users in this entry. One uniqueMember attribute will represents one user. This means we need to add three more uniqueMember attributes for a total of four uniqueMember attributes.
9. Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
10. On the Attribute type field, enter uniqueMember.
11. Click Next, then click Finish.
12. We're back on the Attributes window. We need to add two more uniqueMembers (for a total of four uniqueMembers). Repeat the same steps for adding an attribute.
13. Now we need to fill-in the values for these attributes. In each entry add the dn of each user. Here are the Distinguished Name for each user.
cn=Hugo Williams,ou=users,o=mojo cn=John Keats,ou=users,o=mojo cn=John Milton,ou=users,o=mojo cn=Robert Browning,ou=users,o=mojo
14. Click Finish when you're done.
A new entry has been added under the ou=groups. The new entry is cn=User
Now we need another entry for the Admin role. We'll repeat the same steps.
1. Go to the LDAP Browser panel. Expand the Root DSE folder.
2. Expand the o=mojo entry.
3. Right-click the ou=groups entry. Select New. Select New Entry.
The Entry Creation Method window will appear.
4. Select Create entry from scratch. Click Next. The Object Classes window will appear.
5. Find the groupOfUniqueNames object. Select it then click Add.
6. Click Next. Now you need to enter a Distinguished Name (dn).
The Parent field should read ou=groups,o=mojo.
On the RDN field enter cn. On the value field enter Admin
The DN Preview should read cn=Admin,ou=groups,o=mojo
7. Click Next. The Attributes window will appear. Examine the values.
Notice there's a uniqueMember attribute. We'll be placing the Distinguished Name (dn) of our users in this entry. One uniqueMember attribute will represent one user. This means we need to add one more uniqueMember attributes for a total of two uniqueMember attributes.
8. Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
9. On the Attribute type field, enter uniqueMember.
10. Click Next, then click Finish.
11. We're back on the Attributes window. We need to add one more uniqueMembers (for a total of two uniqueMembers). Repeat the same steps for adding an attribute.
12. Now we need to fill-in the values for these attributes. In each entry add the dn of each user. Here are the Distinguished Name for each user.
cn=Hugo Williams,ou=users,o=mojo cn=John Keats,ou=users,o=mojo
13. Click Finish when you're done.
A new entry has been added under the ou=groups. The new entry is cn=Admin
Here's the final structure:
Exporting the Data
If you need to backup your data or replicate the information in your LDAP, you can export the data. When the data is exported, it's saved in LDIF format. This format is actually a human-readable file. Here's the LDIF for this tutorial:
version: 1 dn: o=mojo objectClass: organization objectClass: extensibleObject objectClass: top o: mojo dn: ou=users,o=mojo objectClass: extensibleObject objectClass: organizationalUnit objectClass: top ou: users dn: ou=groups,o=mojo objectClass: extensibleObject objectClass: organizationalUnit objectClass: top ou: groups dn: cn=User,ou=groups,o=mojo objectClass: groupOfUniqueNames objectClass: top cn: User uniqueMember: cn=John Milton,ou=users,o=mojo uniqueMember: cn=Robert Browning,ou=users,o=mojo uniqueMember: cn=Hugo Williams,ou=users,o=mojo uniqueMember: cn=John Keats,ou=users,o=mojo dn: cn=Admin,ou=groups,o=mojo objectClass: groupOfUniqueNames objectClass: top cn: Admin uniqueMember: cn=Hugo Williams,ou=users,o=mojo uniqueMember: cn=John Keats,ou=users,o=mojo dn: cn=Robert Browning,ou=users,o=mojo objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top cn: Robert Browning sn: Browning uid: rbrowning userPassword:: cGFzcw== dn: cn=John Keats,ou=users,o=mojo objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top cn: John Keats sn: Keats uid: jkeats userPassword:: cGFzcw== dn: cn=Hugo Williams,ou=users,o=mojo objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top cn: Hugo Williams sn: Williams uid: hwilliams userPassword:: cGFzcw== dn: cn=John Milton,ou=users,o=mojo objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top cn: John Milton sn: Milton uid: jmilton userPassword:: cGFzcw==That's it. We've managed to setup our basic LDAP structure using Apache Directory Studio. We've also covered some of the popular LDAP objects.
|
Share the joy:
|


































Great tutorial, thank you very much
ReplyDeleteHelped me very much, thanks!
ReplyDeleteVery helpful tutorial. Thanks for sharing.
ReplyDeleteIt helped me a lot..... thanks!!!
ReplyDeletevery helpful. thanks for your effort in writing this!
ReplyDeleteThis is a very well written article. Thank you for taking to time to contribute this!
ReplyDeleteMy only question here would be:
ReplyDeleteWhat is the password of the connection that was created?
Nevermind, found a good resource that has that information:
ReplyDeletehttp://directory.apache.org/studio/static/users_guide/ldap_browser/gettingstarted_create_connection.html
Just search for default bind password.
Thanks!
password: secret
ReplyDeleteGood way to start handling data from an LDAP repository with dummy values. Thanks!
ReplyDeletethis is da best LDAP tutorial ever !
ReplyDeletethx a lot that help me v v much.
Typo under Add the Organizational Units:
ReplyDeleteYou said:
The same convention applies to groups. The Distinguished Name (dn) is ou=users,o=mojo.
I think you meant:
The same convention applies to groups. The Distinguished Name (dn) is ou=groups,o=mojo.
great tutorial..............
ReplyDeleteafter creating different user can we authenticate user based on password and email id.......
I liked this tutorial - It opened my eyes.
ReplyDeleteI liked it so much that I went back to the top to add another organization, but when I did, I got an error. I can't add another organization?
Very much thankful to you, Nicely created start up
ReplyDelete-Ashish
Thanks, A Million
ReplyDeleteYou really help me.
Exactly what I needed !
ReplyDeleteThanks
Mozart Brocchini
Just wanted to say thank you for all the great tutorials. Your tutorials were the only ones (out of many I walked through) that actually helped me understand and successfully implement my own variation. Thanks!
ReplyDeleteReally good!Nice job
ReplyDeleteOne of the most simple and effective tutorial i have ever found on web for setting up Apache DS. Great job, keep it up. By the way, would it be possible to extend this tutorial or write up another tutorial to configure with tomcat server.
ReplyDeleteThanks
Devendran
Greate tutorial.nothing to say.Thanks a lot
ReplyDeleteThanks it is good material.
ReplyDeleteGreat Help for the LDAP learners,For me its more than great.Many thanks dear..
ReplyDeleteFantastic getting started tutorial, much appreciated
ReplyDeletewhat's after this ??
ReplyDeletehow to authenticate the user now ... i mean where we need to modify the code to authenticate the user on login screen ??
@Anonymous, have you checked the Tutorials section? This guide isn't meant to do any authentication. It's just for setting-up LDAP visually with Apache Directory Studio. Nothing more, nothing less. Try looking at the following guides:
ReplyDeletehttp://krams915.blogspot.com/2011/01/spring-security-mvc-using-ldap.html
http://krams915.blogspot.com/2011/01/spring-security-mvc-using-embedded-ldap.html
Thank you so much. This is the best tutorial that I had ever found on internet. Simple, Easy and Effective. Wonder of Thanks!!!!
ReplyDeleteFahad Sheikh
Thanks man! You saved my time. I was really struggling to add the organization at root level. That Partition thing did the trick for me. Your blog surpasses the apache documentation!
ReplyDeleteGood Work....
ReplyDeleteThanks alot, this helps me to understand in deeper the ldap.
ReplyDeleteGood job !
thank you this is helpful
ReplyDeleteNice tutorial, thanks. Was totally newbie to Directory service and LDAP, but now I can handle it.
ReplyDeleteI really appreciate you work, it is helped me a lot. Nice post.
ReplyDeleteExcelente Tutorial!!! Saludos desde Chile!!!
ReplyDeleteNice tutorial.
ReplyDeleteIf I want to modify the structure of the tree then is how to do this apacheDS?
Thank you very much man... really helpful
ReplyDeleteTHX!
ReplyDeleteGreat tutorial! like all the other ones!. Do you know something about to synchronize apacheDS with a user table in Oracle?
ReplyDeletean LDAP tutorial can't get better than this! Thanks a lot.
ReplyDeleteExcellent tutorial.. there are very few resources for LDAP beginners and this is the only one I was able to understand and follow. I have successfully used pGina on my Windows machines for testing, and I can authenticate to ApacheDS.. But the users are not added to any groups on the machines, so I really can't do anything.
ReplyDeleteIs there something I'm missing? or do I need to add anything to my configuration to tell Windows what Group each user should be a member of ?
Thanks !
Thanks a lot...!!!!! made my work less cumbersome... :)
ReplyDeleteHi Krams,
ReplyDeleteWhen i am restarting the apache -ds-server then it is not starting again please give a suggestion and please send the complete example with jar files.
i have read your blogs and follow your blogs but when i stop the apche-ds-server and again starts the server then it is not start.
And when i an trying to add manually "Root DSE tree because we need to add the organization manually in the tree" then error is coming on on LDAP Browser.
"#!RESULT ERROR
#!CONNECTION ldap://localhost:10389
#!DATE 2012-06-17T18:19:01.332
#!ERROR [LDAP: error code 50 - INSUFFICIENT_ACCESS_RIGHTS: failed for Modify Request Object : '' Modification[0] Operation : delete Modification namingContexts: ou=schema Modification[1] Operation : add Modification namingContexts: ou=mojo : ERR_17 The rootDSE cannot be modified!]
dn:
changetype: modify
delete: namingContexts
namingContexts: ou=schema
-
add: namingContexts
namingContexts: ou=mojo
-
"
great!
ReplyDeleteFantastic tutorial - thanks kindly. A suggestion for a follow-up: Setting up access controls in ApacheDS
ReplyDeleteextending on the comment above, specifically, how do you add access controls to allow users to change only their own password, and allow admin group members to change anything?
ReplyDeleteIt saved my life!!!
ReplyDeleteI needed to get a quick LDAP directory up and running in order to test some Grails code. The Apache documentation seemed to be leaving out some key points, so I did another search and found this. Easy and complete! Thanks for your excellent work.
ReplyDeleteAfter playing with this stuff for two days, it's nice to see a tutorial written in plain English! Thank you!
ReplyDeleteThis is my first time working with LDAP. I found this tutorial very helpful to understand core of LDAP. Thanks!!
ReplyDeleteVery helpful my first time also!! Thank you a lot!!
ReplyDeleteThanks!!
ReplyDeleteThanks a lot for shared a good article in the serious world !!
ReplyDeleteThank you very much. It is very helpful.
ReplyDeleteThanks a bunch. Great article!
ReplyDeleteThanks a lot.... Helped me a lot.
ReplyDeleteExcellent tutorial, Thanks!
ReplyDeleteJust an FYI - the instructions here do not seem to work correctly with ApacheDS 2.0. For some reason the default configuration of ApacheDS has changed such that it is not possible to add an organization at the top level. Apache Directory Studio will report a error when attempting to add an objectClass of organization to the root DSE.
ReplyDeleteExcellent Tutorial Very Neatly explained
ReplyDeleteMuy buen tutorial muchas gracias!!!
ReplyDeletefrom Uruguay :D
Hi,
ReplyDeleteI have 2 queries. Please can help or direct me regarding these: We are currently using WSO2 4.0 M8. We created some users and were using Apache Studio to view the Apache DS schema embedded in the WSO2 identity server
We were able to see the user details, claims, uid etc. But, we are not able to see the gid (POSIX GID - Group id).
And we were not able to add it as a new attribute as it is not displayed in the attribute Type list (drop down box). But the Schema Browser tab shows gidNumber attribute type in it.
We want to view the GiDs of the users. Please do tell us a way to add gid as a new attribute so I can view the user’s Gid.
2. Furthermore I also want to add PAM as an "ou" and use PAM for authentication and Mapping LDAP users to Linux user groups how can I go about this.
Thanks in advance.
Well done. Thanks.
ReplyDeleteVery good tutorial.. I like to thank the contributor for sharing his knowledge..
ReplyDeletepls help me to add new user to apache DS through java code
ReplyDeleteVery well presented.
ReplyDeleteThis articles help a lot!! Tx a million!!
ReplyDeleteSimplest of all. Did it even if I donno anything of ldap...
ReplyDeleteThank you.
This post was really helpful. Thanks
ReplyDeleteThis tutorial was helpful...
ReplyDeleteThanks a lot
Bits
Really nice tutorial man... thank you!! You made me avoid to read extense official documentation :D
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNice tutorial! Thank you!
ReplyDeleteThanks you for the tutorial. It was really helpful and informative
ReplyDeleteMan you are Rock! . I am using Apache client API in Java to connect to DS for my Security system Authentication system. It uses Active Directory and Apache DS. This way I can create/modify/edit Users, GROUPs and OUs, easily form my front end in human readable format. I have to emulate this steps in Java using API. Thank you so much for putting this simple tutorial.
ReplyDeleteI'M NOT ABLE TO CREATE A SERVER ,THAT OPTION IS NOT AVAILABLE IN MY APACHE DIRECTORY STUDIO.WHAT SHOULD I DO?
ReplyDeleteHi Krams,
ReplyDeleteI'm also facing the same problem as no apacheds server option available in apache directory studio v2.0
Nice tutorial! Thank you!
ReplyDeleteThank you sir !! Very well explained !
ReplyDeleteThanks Krams,
ReplyDeleteIt Really helped me .
Thanks for tutorial krams
ReplyDeleteGreat Stuff. Thanks a lot
ReplyDelete