Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to do one of the following in an LDIF file?

  • Ignore error (attr not found) when trying to delete an attribute


  • If attribute exists, modify it
  • If it doesn't exist, add it
share|improve this question
up vote 3 down vote accepted

The right way to do this is simply using the replace action

dn: ...
changetype: modify
replace: attributeName
attributeName: xxx
share|improve this answer

ldapmodify has a -c flag:

-c         continuous operation mode (do not stop on errors)

... which I guess should take care of your first point.

share|improve this answer
Oddly, using -c doesn't seem to do anything. According to the man page this is exactly what I want. Excellent answer... if it worked. I tested and confirmed ldapmodify works fine if I remove the delete: of the non-existent attribute and errors (16) with or without -c otherwise. – user1844882 Jan 21 '13 at 17:40
Solved: Problem was that it has to be done in completely separate entries in the LDIF -- one entry for the delete, then another separate entry for successive actions such as add. – user1844882 Jan 21 '13 at 21:34

Your Answer


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.