Score:0

openldap index existing values

ae flag

I have a ldap database that has been used for some time. naturally it is full on entries.

I recently tried to set up an index for uid to help searching, i added the following to my slapd.conf file

include         /etc/openldap/schema/core.schema
database bdb
suffix "dc=domain,dc=net"
directory /var/lib/ldap
index uid eq,pres


I then ran slapindex

slapindex -f /etc/openldap/slapd.conf -b "dc=jhc,dc=net" uid

But this didnt seem to do it, i dont know if this part is correct but to make any progress the only thing that worked seemed to be adding the following line to a db ldif file in /etc/openldap/slapd.d/cn=config/

olcDbIndex: uid pres,eq

I then ran the slapindex again and started ldap. Searching for a uid is now much faster but doesnt give me a result on entries that where already in the db only new entries show when i do an ldapsearch and filter for the uid, for reference the search is below but i have taken out details of my ldap server

ldapsearch  "cn=admin,dc=domain,dc=net" -b "cn=users,dc=domain,dc=net" "(uid=newuser)"

What am i missing to get entries that already exist to be indexed?

Score:0
ae flag

For anyone with this issue the solution is to essential migrate your DB and add in the new index attribute to the config.ldif file, for me this was done by running

slapcat -n 0 -l config.ldif
slapcat -n 2 -l data.ldif

Then remove the files in /etc/openldap/slapd.d and /usr/local/openldap/

Edit the the config.ldif file and add in your index value, if you have other index values just copy them for me it looked like this

olcDbIndex uid eq

The final step is to add your DB back with your two ldif files

slapadd -c -F /etc/openldap/slapd.d -n 0 -l config.ldif
slapadd -c -F /etc/openldap/slapd.d -n 2 -l data.ldif

You should be able to start ldap now, make sure your ldap user is the owner of the openldap folders and its contents.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.