Building an LDAP Server on Linux, Part 4

Learn the ins and outs of LDAP as well as how to build your own LDAP server in this four-part series. The final installment of the series covers adding security to your OpenLDAP server.

 By Carla Schroder
Page 1 of 3
Print Article

So, you have come back for more OpenLDAP fun (you glutton for punishment, you). Welcome to the final installment of this series, where we'll be discussing how to add security to our OpenLDAP server.

As a quick review of the series, part 1 served as an introduction to the Lightweight Directory Access Protocol, with a breakdown of what the protocol can and cannot do. In part 2 we covered installation and a very basic configuration, while part 3 looked at populating a directory with actual data as well as how to avoid some of the more common showstoppers.

Let's start today's security coverage with a quick look at how to hash your password.

Password Hash

We don't want to store the rootpw in cleartext on the server, so we need to hash it instead. There are several commonly-used hashing methods available via the slappasswd command, including SHA, SSHA, MD5, and CRYPT. CRYPT is the weakest; don't use it. SSHA is the default, and MD5 is good as well. Use slappasswd to generate a nice hashed rootpw:

$ slappasswd
New password:
Re-enter new password:

Now copy & paste this nice fresh hash into /etc/ldap/slapd.conf:

rootpw        {SSHA}Lr7P++EoH6GpIS4GZ36vkV4R422RuW7R

This can be a permanent arrangement. It's fine for a small, simple LAN. An even better solution would be to create an LDAP record that defines the LDAP administrator, and then define access rights for the LDAP admin using ACLs (access control lists) in slapd.conf. Please see the OpenLDAP Administrator's Guide for an excellent chapter on ACLs — it's the best tutorial I've seen on ACLs.


By default, OpenLDAP sends traffic over the network in cleartext, including passwords and logins. Adding encryption foils snoopers and eavesdroppers. To add it, you'll need:

Cyrus SASL

These should already exist on your system. If they're not, first take a minute to cuss and then visit your installation disks or your distribution's Web site to get them. On Debian, look for libssl and libsasl; on RPM-based systems, look for openssl, cyrus-sasl, and cyrus-sasl-md5. (If you feel the need to freak out at this point, go ahead. LDAP is quite complex, so freaking out is an accepted, normal reaction.)

Page 2: Generating a TLS Certificate

This article was originally published on Dec 10, 2003
Get the Latest Scoop with Networking Update Newsletter