[python-ldap] Capture Results

Michael Ströder michael at stroeder.com
Mon Nov 21 21:41:11 CET 2011

Tom Tucker wrote:
> How do I display the results from my last add, change or delete? 

What result do you expect? The write operations usually do not return a
meaningful result except you used a special LDAPv3 extended control before.

> I am missing
> something using the "result" method.  
> Thank you in advance.
>         l = ldap.initialize("ldap://localhost:389/")
>         dn = "uid=%s,ou=people,dc=autotrader,dc=com" % (modifier)
>         l.simple_bind_s( dn, modifier_passwd)
>         dn="uid=%s,ou=People,dc=autotrader,dc=com" % (user_to_be_modified)
>         mod_attrs = [ (ldap.MOD_REPLACE, attr, value)]
>         execute_results = l.modify_s(dn, mod_attrs)
>         result_type, result_data = l.result(execute_results, 0)

You should make yourself more familiar with the difference of asynchronous
call modify() and synchronous call modify_s().

See http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.modify

Also in general the first note here:


So when using

execute_results = l.modify_s(dn, mod_attrs)

the var execute_results contains the result (which is None) whereas

execute_results = l.modify(dn, mod_attrs)

the var execute_results contains the message ID to be used when calling
l.result() afterwards as you did.

Ciao, Michael.

More information about the python-ldap mailing list