Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been doing some testing with ldapadd and ldapmodify and what I noticed is:

-ldapadd will fail if the entry already exists:

=> hdb_tool_entry_put: txn_aborted! DB_KEYEXIST: Key/data pair already exists (-30995)
ldapadd: could not add entry dn="mail=test1@example.org,ou=People,dc=example,dc=org" (line=1): txn_aborted! DB_KEYEXIST: Key/data pair already exists (-30995)

-ldapmodify will fail if the entry doesn't:

modifying entry "mail=test2@example.org,ou=People,dc=example,dc=org"
ldap_modify: No such object (32)
matched DN: ou=People,dc=example,dc=org

Therefore when restoring a backup on an existing database with some existing and some missing entries you can't just use either of these tools, you need to create a routine that:
-either deletes all the users that already exists in the database and are present in the backup and then import using ldapadd.
-or converts the backup ldif file to be ldapmodify-compatible (add or modify depending on whether the user exists) and use ldapmodify.

Q: Isn't there a tool that would take care of that for you?

Additional info: running openldap 2.4.21 on ubuntu server 10.04

share|improve this question
    
In case, the assertion control can help with this sort of thing. –  Terry Gardner Dec 2 '11 at 14:32
    
try ldapmodify with flags -ac. –  Senthil Kumar Aug 3 '13 at 18:10

1 Answer 1

up vote 1 down vote accepted

You can either give the -a flag to ldapmodify or put the line changetype: add into your LDIF data if you add an entry, and changetype: modify to modify the entry.

share|improve this answer
    
Unless I'm mistaken, change using changetype: modify you then have to create replace/add/remove statements for each attribute you're importing like changetype: modify \N replace: cn \N cn: test etc.. –  user64204 Dec 2 '11 at 10:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.