PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` """ ldap.async - handle async LDAP operations See http://www.python-ldap.org/ for details. \$Id: async.py,v 1.33 2013/09/21 03:55:38 stroeder Exp $ Python compability note: Tested on Python 2.0+ but should run on Python 1.5.x. """ import ldap from ldap import __version__ _searchResultTypes={ ldap.RES_SEARCH_ENTRY:None, ldap.RES_SEARCH_RESULT:None, ldap.RES_SEARCH_REFERENCE:None, } _entryResultTypes={ ldap.RES_SEARCH_ENTRY:None, ldap.RES_SEARCH_RESULT:None, } class WrongResultType(Exception): def __init__(self,receivedResultType,expectedResultTypes): self.receivedResultType = receivedResultType self.expectedResultTypes = expectedResultTypes Exception.__init__(self) def __str__(self): return 'Received wrong result type %s (expected one of %s).' % ( self.receivedResultType, ', '.join(self.expectedResultTypes), ) class AsyncSearchHandler: """ Class for stream-processsing LDAP search results Arguments: l LDAPObject instance """ def __init__(self,l): self._l = l self._msgId = None self._afterFirstResult = 1 def startSearch( self, searchRoot, searchScope, filterStr, attrList=None, attrsOnly=0, timeout=-1, sizelimit=0, serverctrls=None, clientctrls=None ): """ searchRoot See parameter base of method LDAPObject.search() searchScope See parameter scope of method LDAPObject.search() filterStr See parameter filter of method LDAPObject.search() attrList=None See parameter attrlist of method LDAPObject.search() attrsOnly See parameter attrsonly of method LDAPObject.search() timeout Maximum time the server shall use for search operation sizelimit Maximum number of entries a server should return (request client-side limit) serverctrls list of server-side LDAP controls clientctrls list of client-side LDAP controls """ self._msgId = self._l.search_ext( searchRoot,searchScope,filterStr, attrList,attrsOnly,serverctrls,clientctrls,timeout,sizelimit ) self._afterFirstResult = 1 return # startSearch() def preProcessing(self): """ Do anything you want after starting search but before receiving and processing results """ def afterFirstResult(self): """ Do anything you want right after successfully receiving but before processing first result """ def postProcessing(self): """ Do anything you want after receiving and processing all results """ def processResults(self,ignoreResultsNumber=0,processResultsCount=0,timeout=-1): """ ignoreResultsNumber Don't process the first ignoreResultsNumber results. processResultsCount If non-zero this parameters indicates the number of results processed is limited to processResultsCount. timeout See parameter timeout of ldap.LDAPObject.result() """ self.preProcessing() result_counter = 0 end_result_counter = ignoreResultsNumber+processResultsCount go_ahead = 1 partial = 0 self.beginResultsDropped = 0 self.endResultBreak = result_counter try: result_type,result_list = None,None while go_ahead: while result_type is None and not result_list: result_type,result_list,result_msgid,result_serverctrls = self._l.result3(self._msgId,0,timeout) if self._afterFirstResult: self.afterFirstResult() self._afterFirstResult = 0 if not result_list: break if not _searchResultTypes.has_key(result_type): raise WrongResultType(result_type,_searchResultTypes.keys()) # Loop over list of search results for result_item in result_list: if result_counter