Schema conversion – LDAP to LDIF
The power of directory service is possibility to define your own object classes, attributes, rules and so on. It also allows grouping it in schemas, which you can add to LDAP configuration.
As for now most of schemas, which you can find in Internet is organized into blocks, which contains definitions of attributes and object classes. This looks like:
attribute type definition:
attributetype ( 126.96.36.199.4.1.323188.8.131.52.9 NAME 'accountStatus' DESC 'The status of a user account: active, disabled' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreSubstringsMatch SYNTAX 184.108.40.206.4.1.14220.127.116.11.26 SINGLE-VALUE )
object class definition:
objectclass ( 18.104.22.168.4.1.32322.214.171.124.2 NAME 'mailAdmin' DESC 'Mail Domain Admin' SUP top STRUCTURAL MUST ( mail ) MAY ( domainGlobalAdmin $ description $ enabledService $ userPassword $ accountStatus $ cn $ sn $ givenName $ preferredLanguage $ givenName $ expiredDate $ mailHost $ lastLoginDate $ accountSetting ))
those definitions are from iredmail.schema, which I use here as example (I put it in attachement too).
If you use static configuration in
slapd.conf file, you can just simply put this file in
/etc/ldap/schema directory, point it in configuration and restart server. But I suppose that you use dynamic configuration, so you need to convert it to LDIF format.
For this purpose I recommend to use perl script, which I get from site: http://directory.fedoraproject.org/download/ol-schema-migrate.pl (also in attachement, hint: you need to change name).
/usr/bin/sudo -i cd /etc/ldap/schema wget http://iredmail.googlecode.com/hg/iRedMail/samples/iredmail.schema wget http://directory.fedoraproject.org/download/ol-schema-migrate.pl
NOTE: the script is not very actual and you need to patch it before use. I do not know perl well, but I corrected this and it works for me. Patch is in attachement, download it and patch as follows:
patch -p0 < drf-ol-schema-migrate.patch
Now you can convert schema:
perl ol-schema-migrate.pl -b iredmail.schema > iredmail.ldif
So, you have converted schema, it is time to add this to directory service:
ldapadd -Y EXTERNAL -H ldapi:/// -f iredmail.ldif
Another way to move schemas (exactly all configuration) from
slapd.conf file to dynamic form is with use of
slaptest utility. Please check OpenLDAP documentation.