4

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

3 Answers3

5

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

dn: ...
changetype: modify
replace: attributeName
attributeName: xxx
4

ldapmodify has a -c flag:

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

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

nickgrim
  • 4,592
  • 1
  • 21
  • 28
1
dn: ...
changetype: modify
add: attributeName
attributeName: xxx
-
delete: attributeName 
attributeName: value
-
delete: attributeOther

May also work for you. This allows multiple operations while listing the DN once.