how to use modlist?

Wido Depping wido.depping at
Tue Jan 4 13:41:42 CET 2005

On Tue, 04 Jan 2005 16:12:12 +0700, tnd at <tnd at> wrote:
> Sorry for my stupid question but the document on ldap.modlist is not
> clear and no example.
> I've tried to use function addModlist like below
> ldap.modlist.addModlist(['key','value'])
> and receive the error
> ...
> AttributeError: 'list' object has no attribute 'keys'
> Could you give me a small example to use modlist correctly.
> Thanks.
> (--ntdt--)

addModlist works on the dictionary of an entry which you get for every
search result. You get something like this: [('cn=foo,o=bar',
{'objectClass': ['top', 'account'], 'uid': ['1028'], 'cn': ['Foo
Bar']}), (second result)]
Get the data dictionary and use addModlist. See here some sample code
from the python console:
>>> a = {'objectClass': ['top', 'account'], 'uid': ['1028'], 'cn': ['Foo Bar']}
>>> import ldap.modlist
>>> ldap.modlist.addModlist(a)
[('objectClass', ['top', 'account']), ('uid', ['1028']), ('cn', ['Foo Bar'])]

The result is your modlist. I hope this makes verything clear.

Wido Depping
ICQ: 51303067    AIM: wido3379
Jabber: wido at

More information about the python-ldap mailing list