diff options
author | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-28 16:01:07 -0700 |
---|---|---|
committer | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-28 16:01:07 -0700 |
commit | e9bd8dee3b0350c08d16d57bfd008a72cb283c48 (patch) | |
tree | f02ea70f613862f2e668bbdb691c25295d3aba20 /ipa-server/ipaserver/ipaldap.py | |
parent | ef2dc5cefa2f9ba94edea7cfce8913e3f25723bd (diff) | |
download | freeipa-e9bd8dee3b0350c08d16d57bfd008a72cb283c48.tar.gz freeipa-e9bd8dee3b0350c08d16d57bfd008a72cb283c48.tar.xz freeipa-e9bd8dee3b0350c08d16d57bfd008a72cb283c48.zip |
Change user search to be asynchronous.
This way it returns results even if the search times out.
The find_users() search now returns a counter as the first result, which
is set to -1 if the results are partial.
Diffstat (limited to 'ipa-server/ipaserver/ipaldap.py')
-rw-r--r-- | ipa-server/ipaserver/ipaldap.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py index f626f2f3a..4d0630eef 100644 --- a/ipa-server/ipaserver/ipaldap.py +++ b/ipa-server/ipaserver/ipaldap.py @@ -300,6 +300,44 @@ class IPAdmin(SimpleLDAPObject): return all_users + def getListAsync(self,*args): + """This version performs an asynchronous search, to allow + results even if we hit a limit. + + It returns a list: counter followed by the results. + If the results are truncated, counter will be set to -1. + """ + + sctrl = self.__get_server_controls__() + if sctrl is not None: + self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl) + + entries = [] + partial = 0 + + try: + msgid = self.search_ext(*args) + type, result_list = self.result(msgid, 0) + while result_list: + for result in result_list: + entries.append(result) + type, result_list = self.result(msgid, 0) + except (ldap.ADMINLIMIT_EXCEEDED, ldap.SIZELIMIT_EXCEEDED), e: + partial = 1 + except ldap.LDAPError, e: + raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e) + + if not entries: + raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND, + "no such entry for " + str(args)) + + if partial == 1: + counter = -1 + else: + counter = len(entries) + + return [counter] + entries + def addEntry(self,*args): """This wraps the add function. It assumes that the entry is already populated with all of the desired objectclasses and attributes""" |