Putting OpenLDAP to Work
Information inside an LDAP directory is stored in "entries". Each entry is a collection of attributes that have a globally unique Distinguished Name (DN), which contain a type and one or more values. An example of a type would be "mail", the value of which is an e-mail address. On the LDAP server, this information is arranged in a tree-like fashion from top to bottom. Typically, at the top of this tree you define the country (c=US) or domain (dc=com). Below this, we might have an organization (o=Acme) and organizational units (ou=People). An organizational unit can contain all your Human Resource employees, printers in a building or any other kind of category. In turn, each attribute contained under the organizational unit is controlled by an objectClass. The value of each objectClass attribute obeys a schema or set of rules that add attribute capabilities to your directory. For example, the inetorgPerson objectClass requires the sn (surname) and cn (common name) attributes but also allows optional entries like mail, telephoneNumber and localityName (see example below).
Designing the directory structure is one of the most important aspects of LDAP. We are going to use a simple example, which we will access with Netscape Address Book. Suppose there is a company called Acme (o=Acme), which is located in several states throughout the US (c=US). Acme wants to implement a small address book server for all its employees. We start out with a simple organizational DN.
dn: o=Acme, c=US
All of Acme's organizations and attributes will be stored under this DN, which is unique to the directory stored on the server. Acme wants to organize its employees under two departments, Managers (ou=Managers) and Employees (ou=Employees). The resulting relative distinguished names (RDN), meaning relative to the top DN, are
dn: ou=Managers, o=Acme, c=US
dn: ou=Employees, o=Acme, c=US
Below you will see the hierarchical structure forming, with US at the top, down to our Management organizational unit and, thus, each individual employee. Acme is just starting out, so let's begin by constructing one manager and two employee entries.
dn: cn=Jason H. Smith, ou=Managers, o=Acme, c=US
dn: cn=Ray D. Jones, ou=Employees, o=Acme, c=US
dn: cn=Eric S. Woods, ou=Employees, o=Acme, c=US
To reference the common name entry Jason H. Smith, LDAP starts by taking the RDN cn=Jason H. Smith, and concatenating the previous parent entries till it reaches the top level DN.
cn=Jason H. Smith
+ ou=Managers
+ o=Acme
+ c=US
-> cn=Jason H. Smith, ou=Managers, o=Acme, c=US
Now that we have the basic structure for our directory, importing the data is next. We will place all this information into an LDIF file. LDIF is the default file format for importing directory information. You can easily write Perl scripts to automate the creation of LDIF data files from system files such as /etc/passwd, NIS or you can grab the excellent migration scripts from the resource sidebar below.
The listing shows our test data, save the information as testdata.ldif. More information on this file format can be found in the LDIF man pages, sections five and eight.
Acme DN, which must exist in the directory before we can add any organizational units
dn: o=Acme, c=US objectClass: organization
The o attribute is required here
o: Acme
Manager organization unit DN. This entry must exist in the directory before we can add any managers.
dn: ou=Managers, o=Acme, c=US objectClass: organizationalUnit
The ou attribute is required here
ou: Managers
The first manager DN
dn: cn=Jason H. Smith, ou=Managers, o=Acme, c=US objectClass: inetOrgPerson
Both cn and sn are required attributes
cn: Jason H. Smith sn: Smith
But these are optional attributes
telephoneNumber: 111-222-9999 mail: headhauncho@acme.com localityName: Houston
We can define another organizational unit
dn: ou=Employees, o=Acme, c=US objectClass: organizationalUnit ou: Employees
And add employees below
dn: cn=Ray D. Jones, ou=Employees, o=Acme, c=US objectClass: inetOrgPerson cn: Ray D. Jones sn: Jones telephoneNumber: 444-555-6767 mail: jonesrd@acme.com localityName: Houston dn: cn=Eric S. Woods, ou=Employees, o=Acme, c=US objectClass: inetOrgPerson cn: Eric S. Woods sn: Woods telephoneNumber: 444-555-6768 mail: woodses@acme.com localityName: Houston
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- 100% disappointed with the decision to go all digital.
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- Why Python?
- Linux-Based X Terminals with XDMCP
- The Linux powered LAN Gaming House
- Creating a vDSO: the Colonel's Other Chicken
- buena información
3 hours 39 min ago - One important "bucket" that I didn't note (désolé si qqun deja d
4 hours 39 min ago - Gnome3 is such a POS. No one
14 hours 7 min ago - Gnome 3 is the biggest POS
14 hours 17 min ago - I didn't knew this thing by
20 hours 22 min ago - Author's reply
23 hours 46 min ago - Link to modlys
1 day 53 min ago - I use YNAB because of the
1 day 1 hour ago - Search
1 day 6 hours ago - Question
1 day 6 hours ago





Comments
Great Article
This is the article I was looking for over past 6 months. I was having a lot of trouble understanding LDAP structure and adding ldif files .Now I am very much clear about Open LDAP database structure.
Thank you very much for this useful article.
vinod
Re: Putting OpenLDAP to Work
Excellent Article.....
It helped me a lot...
Thanks
Re: Putting OpenLDAP to Work
hello, i want to know that OpenLdap can hold user 500000 up user? and today where does organize use to implement user 500000 up
please tell me at praek@engineer.com .Thank you
Re: Putting OpenLDAP to Work
Very clear article !!
Re: Putting OpenLDAP to Work
cool article! anymore like it?