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.

The ldapmodify man page states that:

The default for ldapmodify is to modify existing entries

Yet when I try to import an LDIF file with ldapmodify I get the below error:

ldapmodify: modify operation type is missing at line X

Q1: Why, which arguments should I add to my ldapmodify command?

If I import an LDIF file using ldapadd and the entry already exists I get the below error:

ldap_add: Already exists (68)

This can be ignored using the -c switch (for continue), however ldap_add won't update existing entries. Instead, in order to update existing entries one should use ldapmodify, however ldapmodify won't add missing entries.

Q2: Is there a way to import an LDIF files by creating missing entries AND updating existing ones at the same time?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The ldif for ldapmodify has a different syntax then a regular ldif. F.e.: if u want to add the 'foo' entry with value 'bar' u should write your ldif like this:

dn: cn=ToModify,dc=example,dc=com
changetype: Modify
add: foo
foo: bar

replace: mail
mail: new@email.com

delete: unneededEntry

This ldif will add the attribute foo with value bar, update the mail attribut to new@email.com and delete the inneededEntry. then invoke the ldapmodify command.

ldapmodify -f update.ldif 

(if needed with other options like simple auth f.e.)

share|improve this answer
    
Thanks. Are you able to comment on Q2 at all? –  user64204 Jul 14 '11 at 12:39
    
As far as I know this is not possible, therefore u have the 2 tools... ldapmodify for existing entries, ldapadd to add new ones. –  Goez Jul 14 '11 at 13:21
    
That's also the impression that I was getting. Since I don't have to preserve the existing LDAP content before doing the import, I'm going to purge LDAP with ldapdelete then import the LDIF with slapadd. –  user64204 Jul 14 '11 at 13:27
add comment

Goez answer seems fine.

However if you are unfamiliar with ldif it can make sense to use

ldapvi

instead. You can edit already existing entries or add new ones.

apt-get install ldapvi
share|improve this answer
    
Thanks but it doesn't scale up. For individual entry editing I'd much rather use something like this directory.apache.org/studio. –  user64204 Jul 14 '11 at 12:58
add comment

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.