Add new schema to OpenLDAP in 4 steps

I always foget how to do that so here is the tiny tutorial.

Step 1

create a conversion converted_schema.conf file containing the following line(s):

include /etc/ldap/schema/[shema_0].schema
include /etc/ldap/schema/[shema_1].schema
...

Step 2

Convert the schema using:

$ mkdir /tmp/ldif_output
$ slaptest -f converted_schema.conf -F /tmp/ldif_output

Tweak the converted_schema.conf if conversion did not succeed.

Step 3

Edit the /tmp/ldif_output/cn=config/cn=schema/cn={X}[shema_X].ldif file:

  • Update the first line to: dn: cn={X}[shema_X],cn=schema,cn=config
  • Update: cn: {X}[shema_X]
  • Remove last 7 lines beginning with: structuralObjectClass

Step 4

Add the schema:

$ ldapadd -x -D cn=config -f /tmp/ldif_output/cn\=config/cn\=schema/cn\=\{X\}[shema_X].ldif

Or delete it:

$ ldapadd -x -D cn=config -f /tmp/ldif_output/cn\=config/cn\=schema/cn\=\{X\}[shema_X].ldif

Note: The X has to be next in the row in /etc/openldap/slapd.d/cn\=config/cn\=schema and shema_X is an arbitrary name of the new schema.

Leave a Reply

Your email address will not be published. Required fields are marked *