4.6. Slapd Configuration

First of all, you need to install slapd (the server part of the free OpenLDAP suite). The server configuration is defined in the /etc/ldap/slapd.conf file. The very same file it's used also by slurpd (the daemon managing the replicatoin mechanism).

There are three different type of directives in the configuration file of the server:

The first set of directives set generic parameters for slapd, like the address to bind to, where to put logs, ACLs, and so on...

The second set of options defines parameters needed by the database backend. We decided to use BDB notwithstanding the reported consistency problems (a quick search on the web suggests daily backup of the data), since the other OpenLDAP-supported backend (LDBM) is even officially deprecated...

Last but not least, the third set of options defines parameter to configure the databases (in our case it's a single database), allowing you to specify what indexes to create, where to store teh database, and other options that it's better to check closely. It is absolutely necessary to create an index for each attribute that could be present in a filter. Note that you can create the index at any given moment, so if you forget something you can always add it later (using the slapindex command). However if you missed an index on a frequently used search attribute you will notice it very soon, since a missing index can almost bring a busy server to a complete halt!

4.6.1. Fine Tuning

We will not enter into the detail of the basic slapd configuration that anybody can find in Chpater 6: "The slapd configuration file" of the "OpenLDAP Administration Guide". In this chapter we would like instead to cover the fine tuning we deployed for increased stability and performance. Nearly any operation on the servers, in fact, implies an LDAP request: this lets you understand how important the efficiency of slapd is to the overall system.

The main problem can be faced from two complementary perspectives: on one side we can try to reduce the number of request to the minimum (for example using various sorts of caching mechanisms); on the other side, we need to optimize the slapd configuration so as to get better performances.

As an example of the first perspective we can relief the server of the very frequent NSS requests. Many unnecessary requests can be avoided by specifying the files directive before the ldap directive in /etc/nssswitch.conf, so as to resolve system users without querying the LDAP database right away. The NSS caching daemon nscd can reduce further these queries to the bare minimum.

Concerning the optimization of the slapd configuration, you can find some thoughts below:

4.6.2. ACL

The most complex part of the LDAP server configuration is the creation of the ACL (Access Control Lists) needed to make it work properly. This is due partly to the particularly deranged syntax of the ACL themselves... For each requested uid and for each given requesting uid, OpenLDAP will check the first ACL rule (scanning the file from the top down) that it can apply to the requested uid. Then it will check for the first ACL rule it can apply to the requesting uid. For example the following ACL is needed to controll the access to the userPassword attribute:

access to attrs=userPassword
  by dn="cn=manager,o=anarchy" write
  by group/groupofnames/member=\
        "cn=admins,ou=Group,dc=infra,dc=org,o=Anarchy" write
  by dn="cn=ring0op,ou=Operators,dc=infra,dc=org,o=Anarchy" read
  by dn="cn=ring1op,ou=Operators,dc=infra,dc=org,o=Anarchy" read
  by dn="cn=dovecot,ou=Operators,dc=infra,dc=org,o=Anarchy" read
  by anonymous auth
  by self write
  by * none
	
Modification of the attribute is in any case allowed to ldap manager and to the servers administrators, while operators can only read the attribute to use it for authentication.

The order of ACLs in the configuration files is very important: they need to be written starting with the most specific to the least specific (concerning the access to approach).