best way to make mods to entries

Anil Jangity anilj at entic.net
Fri Jan 19 20:21:10 CET 2007


Whats the recommend way to make modifications to an LDAP entry?

Right now I am using ldap.modify (MOD_ADD,  MOD_DELETE, or
MOD_REPLACE) but it seems cumbersome because there are multiple
possiblities for each modification depending on wether its a
multi-value attribute or single-value or required attribute or
optional attribute...

This is a rough code of what I am talking about:
# optional attr
if attribute not in newentry:
  MOD_DELETE
if new_attribute and old_attribute are diff:
  if old_attr is None:
     MOD_ADD
  else:
     MOD_REPLACE

# required attributes
....


It would be nice if there is a class available to simply pass in the
DN, and the *new* LDIF and it would be taken care of. I am just
looking through some documentation and I guess something like
ldif.LDIFWriter().

Unless I am missing something that is there already....

Thanks.




More information about the python-ldap mailing list