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

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

Or:

  • If attribute exists, modify it
  • If it doesn't exist, add it
share|improve this question

2 Answers 2

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

 
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.