Created
February 17, 2014 18:36
-
-
Save ssbarnea/9056355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_ext_s(self, filterstr=None, attrlist=None): | |
pages = 0 | |
timeout = -1 | |
ret = [] | |
serverctrls = None | |
clientctrls = None | |
msgid = self.conn.search_ext( | |
self.base, | |
self.scope, | |
filterstr=filterstr, | |
attrlist=attrlist, | |
attrsonly=0, # attrsonly, | |
serverctrls=(serverctrls or []) + [self.req_ctrl], | |
clientctrls=clientctrls, | |
timeout=timeout, | |
sizelimit=sizelimit | |
) | |
while True: | |
pages += 1 | |
rtype, rdata, rmsgid, serverctrls = self.conn.result3(msgid, resp_ctrl_classes=self.known_ldap_resp_ctrls) | |
ret.extend(rdata) | |
pctrls = [ | |
c | |
for c in serverctrls | |
if c.controlType == SimplePagedResultsControl.controlType | |
] | |
if pctrls: | |
if pctrls[0].cookie: | |
# Copy cookie from response control to request control | |
self.req_ctrl.cookie = pctrls[0].cookie | |
msgid = self.conn.search_ext(self.base, self.scope, filterstr=filterstr, attrlist=attrlist, serverctrls=[self.req_ctrl]) | |
else: | |
break | |
else: | |
print "Warning: Server ignores RFC 2696 control." | |
break | |
# FIX for Microsoft bug: ldap.UNAVAILABLE_CRITICAL_EXTENSION: {'info': '00002040: SvcErr: DSID-031401E7, problem 5010 (UNAVAIL_EXTENSION), data 0\n', 'desc': 'Critical extension is unavailable'} | |
# explain: second pagination query fails, so after a query we will establish a new connection to the server. | |
if pages > 1: | |
self.reconnect() | |
# ret = self.conn.search_ext_s(*args) | |
return ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment