best way to make mods to entries

Michael Ströder michael at
Mon Jan 22 10:46:30 CET 2007

Anil Jangity wrote:
> Whats the recommend way to make modifications to an LDAP entry?

In general
1. you should do as many modifications in a single modify as possible
since a single modify operations is atomic.
2. you should try to avoid mods which need equality matching rules at
the server side for sorting out specific attribute values.

> 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...

Maybe the output of function ldap.modlist.modifyModlist() gives you some

> 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.

Not LDIF. ldap.modlist.modifyModlist() handles dictionaries.

> I am just
> looking through some documentation and I guess something like
> ldif.LDIFWriter().

It's fairly easy to glue ldif.LDIFReader() and
ldap.modlist.modifyModlist() together.

Ciao, Michael.

More information about the python-ldap mailing list