How to add schema in openldap v2.x

Though the following steps you can add new schema in openldap v2.x.  In this tutorial I have already created schema mailserver.schema .

Step-1  Copy your schema ( eg. mailserver.schema ) in /tmp folder and create new folder which will be used to convert schema in ldif format.

[ root @server~]#    cp    mailserver.schema     /tmp

[ root @server~]#    mkdir   /tmp/schema_ldif/

 

Step-2  Copy  slapd.conf.bak  file to /tmp and include new schema file path in it.

[ root @server~]#   cp   /etc/openldap/slapd.conf.bak    /tmp

[ root @server~]#  vim   /tmp/slapd.conf.bak 

include         /tmp/mailserver.schema

ESC

:wq!

 

Step-3  Run the following to convert schema into ldif format. 

[ root @server~]#   slaptest    -f    /tmp/slapd.conf.bak    -F   /tmp/schema_ldif/

 

Step-4  Now copy ldif format schema into the configuration folder and change the ownership & groupship of the file.

[ root @server~]#   cp    /tmp/schema_ldif/cn=config/cn=schema/cn={12}mailserver.ldif

       /etc/openldap/slapd.d/cn=config/cn=schema/

[ root @server~]#   chown    ldap.ldap   /tmp/schema_ldif/cn=config/cn=schema/cn={12}mailserver.ldif

 

Step-5  Restart openldap service.

[ root @server~]#    service   slapd   restart

 

Cheer!!