If LDAP isn't installed as part of the default server installation on your system, you can download and install it from http://www.openldap.org/ or one of its mirror sites. To accomplish the installation, first untar the tarball with something like:
tar -zxvf openldap-stable-xxxxx.tgz
where xxxxx is the version number of the file you downloaded. Then activate the directory created in the preceding step, and run the configure script in this directory. This script verifies that all conditions to install LDAP on your system have been met. Run make; first you make the dependencies with make depend, then you compile the program with just make. Now you can see if everything compiled correctly by running make in the directory /test. Finally, you can actually install the software on your system; type make install in the directory created when you expanded the tarball.
After the installation, you'll find an example of the configuration file slapd.conf in the directory /etc/openldap. You will need to edit it to meet the requirements of your organization. For starters, you don't need to make it too complicated; edit the example file to look something like Listing 1.
Let's take a look at the most important lines in this file. The first two lines are used to include two extra configuration files. In this case, they are the schema files, which are not modified at all, but you do need to instruct slapd as to where it can find them. The line “schemacheck = off” is also not too exciting; it tells slapd that it doesn't have to check the schema. After that there are another two lines that point to some extra files: slapd.pid, which keeps the PID slapd is using, and slapd.args, which keeps the arguments that were used when slapd was started. Then there's the line that defines the kind of database you are using. You can specify ldbm, shell and passwd, but ldbm is the most common.
Then there are three important lines. The first begins “suffix dc=azlan, dc=com”; this line defines the standard container in which slapd should work. In my case, it is equal to the DNS name of the company I work for. Then the name of the account allowed to manage or make modifications to the database is mentioned by its full distinguished name. The third line defines the password used by this manager; as you see, it is written as a plain text password, which isn't very secure, but we'll talk about that later.
The line “directory /usr/local/var/openldap-ldbm” defines the location of the directory where the LDAP database will be installed. Make sure that its mode is 700 and that the owner of the slapd process can read and write to it.
After these lines there are some options that aren't strictly necessary but can be very handy. First is “lastmod on”, an option that keeps track of the users that make modification to objects. For that, the attributes modifiersName, modifyTimestamp, creatorsName and createTimestamp are used. Then we have options that do some indexing. Unfortunately, OpenLDAP isn't the fastest LDAP directory around, so it could be worthwhile to speed things up with some indexfiles. loglevel 64, which accomplishes extensive logging, is good if you want to make things work more quickly. The minimal value for this parameter is 1, the maximum is 256 and between that you can use 2, 4, 8, 16, 32, 64 and 128.
Lastly, there is the specification of some access rights to the directory. The default is “read”, meaning anyone can read anything, including the passwords. The four lines starting with “access to attr=userpassword” contain the specifications for who can do what with the passwords in the directory. The first line specifies that everyone is allowed to modify his or her own password. Root is allowed to write to any password, while normal users can read but not write to passwords (necessary, of course, to be able to log in to the system).
Once you've edited slapd.conf to your satisfaction, the next step is to start the LDAP dæmon slapd. Of course, you could type slapd to do that, but you can also tell it to show you all debug messages by adding the option dn, in which n represents the number of the debug level you'd like to see.
Now you can go on to the next step, which is to add data to the directory. In this example, we'll add some simple data. To do this, you have to compose an LDIF file that could have the contents shown in Listing 2.
If you've made a file like Listing 2, which could be called ~/users.ldif, you can add it to the directory with
ldapadd -D "cn=manager, dc=azlan, dc=com" -W < ~/users.ldif
You will be prompted for your password, which is, of course, the password of the root account as specified in slapd.conf. If everything goes well, the data should now be added to the directory.
Many errors can be solved by verifying whether slapd is really running (oh yeah, it happens) and whether you have any extra spaces in your configuration or LDIF files.
- Give new life to old phones and tablets with these tips!
- Readers' Choice Awards 2014 Poll
- Memory Ordering in Modern Microprocessors, Part I
- Source Code Scanners for Better Code
- Tech Tip: Really Simple HTTP Server with Python
- Linux Systems Administrator
- [<Megashare>] Watch Mrs Brown's Boys Movie Online Full Movie HD 2014
- Senior Perl Developer