[python-ldap] result_type of connection.result()
Dave Peticolas
dave at krondo.com
Thu Feb 2 09:52:46 EST 2017
On Wed, Feb 1, 2017 at 11:31 PM Michael Ströder <michael at stroeder.com>
wrote:
> Dave Peticolas wrote:
> > Hi, I've noticed (using versions 2.4.19 and 2.4.29) that the result_type
> tuple
> > returned by result() is sometimes RES_SEARCH_ENTRY when all=1 using the
> default from
> > not passing in "all" despite the docstring which seems to say it should
> always be
> > RES_SEARCH_RESULT.
>
> Hmm, I'm not 100 % sure about the SearchResultDone:
>
> https://tools.ietf.org/html/rfc4511#section-4.5.2
>
> > The scenario where this is happening is that multiple asynchronous
> searches are started
> > and then the results are requested for each one by explicitly passing
> specific msgid
> > values for each one, but with all=1.
> >
> > Note this doesn't always happen. It seems to be related to the order the
> results are
> > returned from the server.
> >
> > Am I just reading the docstring incorrectly?
>
> Could you please provide some example code for testing this?
> It might also be relevant which LDAP server you're using.
>
>
Oh, right, it's OpenLDAP 2.4.31.
I'll try to work up a more detailed example code but here is the gist:
conn = <establish bound connection>
msg_ids = [conn.search(*query_args) for query_args in queries]
all_results = []
for msg_id in msg_ids:
kind, results = conn.result(msg_id)
if kind != RES_SEARCH_RESULT:
results = []
all_results.extend(results)
Sometimes "kind" will be RES_SEARCH_ENTRY and the results will be ignored.
This is extracted from the django-auth-ldap library which is using code
like the above to search for user records across multiple queries.
https://bitbucket.org/psagers/django-auth-ldap/issues/65/ldapsearchunion-bug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170202/4560992d/attachment-0001.html>
More information about the python-ldap
mailing list