[python-ldap] modifyModlist : are old and new values get compared somehow ?

Michael Ströder michael at stroeder.com
Mon Nov 30 06:58:11 EST 2015


mh at ow2.org wrote:
> In the following code,
> 
>     old = {'attr':['oldvalue']}
>     new = {'attr':['newvalue']}
> 
>     mod = modlist.modifyModlist(old,new)
> 
>     l.modify_s(dn,mod)
> 
> 
> I'm not sure to fully understand the documentation ; it seems the new
> attribute value is modified in all case - whatever the value stored in
> old attr ; in this case what's the point in specifying an 'oldvalue' ?

The function is used for generating a modification list when comparing an old
entry dictionary (of an existing LDAP entry) with a new entry dictionary so
that the resulting LDAP entry after the l.modify_s(dn,mod) will be the new
entry dictionary. The old values are required to determine whether a change is
needed at all.

If you know in advance which modifications you want calling
ldap.modlist.modifyModlist() is not useful at all. Rather then you could

mod = [
  (ldap.MOD_REPLACE,'attr',['newvalue']),
]

As usual YMMV.

Ciao, Michael.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20151130/12282ead/attachment.bin>


More information about the python-ldap mailing list