1

I am new to LDAP and am trying to install it for a computer cluster. I have been going through this technical quick-start guide https://www.openldap.org/doc/admin26/quickstart.html. I have completed all the steps up to 8, but the slapd configuration command at step 9 is giving me trouble.

The guide states - "You are now ready to import your configuration database for use by slapd(8), by running the command: su root -c /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr/local/etc/openldap/slapd.ldif"

The command I run is sudo /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr/local/etc/openldap/slapd.ldif

All the directories listed in the command exist and the corresponding files, symbolic links, and directories also exist. When I run the command, I am met with this error slapadd: could not add entry dn="cn=config" (line=1): Closing DB...

When troubleshooting, I went back to step 8. The end of it states "Note that the specified olcDbDirectory must exist prior to starting slapd(8)." The olcDbDirectory in my slapd.ldif file is /usr/local/var/openldap-data

This directory exists, however I cannot cd into it as I do not have permissions. I was thinking that perhaps this may be one of the reasons for the error I am experiencing. Additionally, in my slapd.d directory (/etc/ldap/slapd.d), I have one directory and one file. These are the contents of the directory: 'cn=config' 'cn=config.ldif' I was reading other posts and read that maybe there are not supposed to be two entries. However, I did not delete anything as I was unsure.

What steps should I take to resolve this issue? I have not found many others with the same error. An important thing to note is that we have tried installing LDAP multiple times previously. Those attempts either failed or gave us unsatisfactory results, so we ended up uninstalling them after. Perhaps we did not uninstall every file which is leading to this error. I appreciate all and any help on this issue. Please let me know if I should provide more information.

Thank you.


1 Answer 1

1

There are two databases involved here:

  • -n 0 is the configuration database (prefix cn=config) which is stored as a bunch of individual LDIF files under /usr/local/etc/slapd.d.

  • -n 1 is your first data database (prefix o=Foo or dc=foo,dc=bar or whatever) which is stored as a LMDB or BDB database under /usr/local/var/openldap-data.

You're trying to import entries into the config database, which is stored in /etc, so the directory in /var is irrelevant at this point yet.

It seems that you might actually have the opposite problem: you're trying to add entries which already exist, as you mentioned that your /etc/ldap/slapd.d directory already has the corresponding .ldif files for them. So you should first remove all files from the slapd.d/ directory before trying to import them with "slapadd" again.

(Alternatively, you could start with an "old style" slapd.conf, then have slapd convert it to LDIF format using slapd -f slapd.conf -F slapd.d.)

Another problem is that you're talking about two different paths for the same thing – at first you're importing into /usr/local/etc/slapd.d, but later you're looking in /etc/ldap/slapd.d, which is not the same.

(Overall, it sounds like you have a system OpenLDAP installation and a custom-compiled one, which both use different paths – that's not a good thing to have. I would really recommend cleaning up this mess and making sure you have one or the other installed…

In fact, I'd also suggest doing everything on a fresh system rather than one which already has a bunch of other stuff running on it.)

1
  • Long story short: your target directory is not empty and contains existing data. rm -rf /usr/local/etc/slapd.d (or the target directory defined by -F ) Commented Jan 29, 2023 at 22:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .