[python-ldap] Adding msgid to LDAPError
michael at stroeder.com
Sat Sep 12 12:09:36 CEST 2015
Michael Ströder wrote:
> Stephen J. Butler wrote:
>> I've run into a situation where I issue a bunch of LDAPObject.search()
>> requests and then loop while calling LDAPObject.result3() waiting for the
>> responses. However, some of my search() requests will return a NO_SUCH_OBJECT
>> error; and I'd like to just ignore that error and wait for the rest of the
>> I can put the result3() in a try/except block, but when the exception happens
>> I won't know which messageID it belongs to. So in a loop like this...
>> while active_msgids:
>> res_type, res_data, res_msgid, res_sctrls =
>> conn.result3(self.result3(msgid=RES_ANY, all=0))
>> except LDAPError as ldapErr:
>> # Process successful result
>> ... the error msgid never gets removed from active_msgids, and I end up
>> looping forever.
>> Attached is a patch that adds "msgid" to LDAPError where it makes sense, which
>> is only for the result() set of methods.
> Thanks for the patch. I will review more carefully later.
> But just a quick question: Why not attach the msgid to also LDAPError
> instances caused by write operations? Note that LDAP allows pipe-lining of
> requests. You can send several write operations and deal with the result code
> later. Your patch would be handy for those situations either.
> While you're at it you could also attach the response controls (plural!)
> returned by the server in the LDAPResult messages to the LDAPError instance.
> This would e.g. solve the case of a simple bind failing because of an expired
> password. Up to now the response control saying "password expired" cannot be
> Also OpenLDAP's experimental "What failed?" control would require this for
> determining what went wrong when using slapo-constraint, slapo-unique...
To add: For a while I've thought about a lock-free variant of LDAPObject class
which would also require this.
More information about the python-ldap