Troubleshooting slapadd
Learn how to troubleshoot common issues with the slapadd command, ensuring smooth data imports in LDAP servers.
Table of Contents
Resuming slapadd
After correcting an issue with an entry in the input ldif, you can resume slapadd
at the point in the ldif where the correction was made using the -j <line-number>
argument. The line at the line number must start with dn:
.
Without this argument slapadd
will fail because it tries to re-add entries already processed in the input ldif file.
Example:
slapadd -f /opt/symas/etc/openldap/slapd.conf -b dc=example,dc=com -l myfile.ldif -j 23 -q
If you want to completely restart the database load, remove the data.mdb file from the database directory (directory <path>
in slapd.conf or olcDbDirectory: <path>
in cn=config.
The slapadd
tool is used for loading LDAP database offline (when slapd isn't running.)
Here are some of the common issues encountered with this tool.
Error: slapadd: could not add entry dn="cn=config" (line=1)
This error occurs when trying to load the cn=config database and the configuration directory, usually /opt/symas/etc/openldap/slapd.d
or /etc/openldap/slapd.d
is not empty. To fix this, simply delete the contents of the directory:
rm -rf /opt/symas/etc/openldap/slapd.d/*
Or
rm -rf /etc/openldap/slapd.d/*
Error: str2entry: entry -1 has no dn slapadd: could not parse entry (line=N)
This error occurs when there is a blank line within an entry in the ldif file. Entries are separated by blank lines in ldif files, so if there's as stray blank line, slapadd will fail because every entry must start with the “dn: " attribute.
To fix this, open your ldif file at the line number given in the error and delete the offending blank line above. Then, you can resume slapadd (see “Resuming slapadd
”).
Error: slapadd: line [N]: cannot add entry with empty dn=""
In LDAP, every entry must have a DN attribute, with one exception (null root databases which handle multiple suffixes.)
To fix this, open your ldif file at the line number given in the error and add the DN. You can then resume slapadd (see “Resuming slapadd
”)
Error: slapadd: line [N]: database #1 ([suffix]) not configured to hold "[DN]"; no database configured for that naming context
This error occurs when the DN of an entry in the ldif file contains has an incorrect suffix. For example, if the suffix of the database is dc=example,dc=com
and the suffix of an entry being added is dc=example,dc=cob
, slapadd will fail with this error.
Fix: Correct the DN of the entry at the line number given in the error and resume slapadd (see “Resuming slapadd
” at the top of this article.)