directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <m...@stefan-seelmann.de>
Subject Re: [Studio] command line equivalent of import
Date Sun, 02 Feb 2014 20:03:34 GMT
On 02/01/2014 06:42 PM, Mihamina RKTMB wrote:
> Reimporting is done with Apache directory Studio by
> - exporting the tree to ldif
> - importing the exported ldif (overwriting existing entries)
> 
> Would you know a scripted way to import as Studio would?

What Studio does is:
1) try to add the entry
2) if that fails with error 68: use changetype:modify and replace each
attribute with all its values defined in the LDIF.

This approach often works but is not a perfect "replace" mechanism. If
an attribute exists within the LDAP server but the same attribute is not
contained in the LDIF then the attribute will not be deleted but remains
unchanged.

So with a script language of your choice you can change the LDIF as
follows (check if you have wrapped lines):

    dn: cn=fbar,ou=users,dc=example.dc=com
    objectClass: person
    objectClass: top
    cn: fbar
    ...

to

    dn: cn=fbar,ou=users,dc=example.dc=com
    changetype: modify
    replace: objectClass
    objectClass: person
    objectClass: top
    -
    replace: cn
    cn: fbar
    -
    ....



Another thing you may do with a bit sed magic: replace the "dn: " lines
(check if you have wrapped lines) with a changetype:delete and a
changetype:add instruction. For Example:

    dn: cn=fbar,ou=users,dc=example.dc=com
    objectClass: person
    ...

becomes

    dn: cn=fbar,ou=users,dc=example.dc=com
    changetype: delete

    dn: cn=fbar,ou=users,dc=example.dc=com
    changetype: add
    objectClass: person
    ...

Note that this will delete each entry first, operational attibutes
(createTimestamp, entryUUID) will change!


Kind Regards,
Stefan


Mime
View raw message