slapd mdb backend on Debian

Debian's slapd package does not let you create a database using the Memory-Mapped Database backend. Here's how to do it. These steps were tested with version 2.4.31-1 of the slapd package.

Note that these steps will create a new database from scratch! If you want to migrate your existing database then make sure you do a backup & restore before/after the procedure.

# service slapd stop
# rm -r /var/lib/ldap/* /etc/ldap/slapd.d/*
# cp /usr/share/slapd/slapd.init.ldif init.ldif

Make the following replacements in init.ldif. See slapd-mdb(5) for additional configuration options.

Initialize a new slapd config directory:

slapadd -v -F /etc/ldap/slapd.d -b cn=config -l init.ldif

Create the mdb database:

cat <<EOF > data.ldif
        dn: dc=example,dc=com
        objectClass: top
        objectClass: dcObject
        objectClass: organization
        o: Example Corp
        dc: example

        dn: cn=admin,dc=example,dc=com
        objectClass: simpleSecurityObject
        objectClass: organizationalRole
        cn: admin
        description: LDAP administrator
        userPassword: admin
slapadd -v -F /etc/ldap/slapd.d -b dc=example,dc=com -l data.ldif

Pay attention to any error messages output by slapadd in the above steps. If anything fails you should remove the relevant databases and re-run slapadd.

Fix up permissions and start the server:

chown -R openldap:openldap /var/lib/ldap /etc/ldap/slapd.d
service slapd start

That wasn't so hard! DebianSlapdMdb (last edited 2012-12-11 12:03:42 by sam)

© Sam Morris <>.
Content may be distributed and modified providing this notice is preserved.