Though the original poster's answer is solved, here's a solution to OpenLDAP 2.4 users. OpenLDAP 2.4 does not use plain config files anymore, but everything has to be modified using ldapmodify
.
First you need to identify your database in question.
[root@ldap-server ~]# cd /etc/openldap/slapd.d/cn=config
[root@ldap-server cn=config]# ls
cn=schema olcDatabase={0}config.ldif olcDatabase={1}monitor.ldif
cn=schema.ldif olcDatabase={-1}frontend.ldif olcDatabase={2}hdb.ldif
The database here is olcDatabase={2}hdb.ldif
and checking for indexes with grep yields:
[root@ldap-server cn=config]# grep olcDbIndex olcDatabase\=\{2\}hdb.ldif
olcDbIndex: objectClass eq,pres
olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
If I need to add, for instance, the poster's index l
, I'd prepare the following ldif-file:
[root@ldap-server ~]# cat ldap-hdb-tuning.ldif
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: ou,description,l eq,pres,sub
The final step would be running the file with ldapmodify
.
[root@ldap-server ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -D cn=config -f ldap-hdb-tuning.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={2}hdb,cn=config"
If you then look into /var/lib/ldap
you'll notice a new index.file named l.bdb
which should be growing if you add new records.
Note that I didn't find out yet if the index creation is being done on the fly for existing records (I'm currently doing that right now) but I will adapt this answer when I know more.