本文整理汇总了Python中ldap.controls.SimplePagedResultsControl.controlValue[1]方法的典型用法代码示例。如果您正苦于以下问题:Python SimplePagedResultsControl.controlValue[1]方法的具体用法?Python SimplePagedResultsControl.controlValue[1]怎么用?Python SimplePagedResultsControl.controlValue[1]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ldap.controls.SimplePagedResultsControl
的用法示例。
在下文中一共展示了SimplePagedResultsControl.controlValue[1]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from ldap.controls import SimplePagedResultsControl [as 别名]
# 或者: from ldap.controls.SimplePagedResultsControl import controlValue[1] [as 别名]
def search(self, base_dn=None, scope=ldap.SCOPE_SUBTREE,
filter='(objectClass=*)', attrs=[]):
conn = self.connect()
if conn is None:
return []
if base_dn is None:
base_dn = self.base_dn
# Get paged results to prevent exceeding server size limit
page_size = 1000
if PYTHON_LDAP_24:
lc = SimplePagedResultsControl(size=page_size, cookie='')
else:
lc = SimplePagedResultsControl(LDAP_CONTROL_PAGED_RESULTS,
True,
(page_size, ''),)
is_last_page = False
results = []
while not is_last_page:
msgid = conn.search_ext(base_dn,
scope,
filter,
attrs,
serverctrls=[lc])
rtype, rdata, rmsgid, serverctrls = conn.result3(msgid)
results.extend(rdata)
pctrls = [c for c in serverctrls
if c.controlType == LDAP_CONTROL_PAGED_RESULTS]
if pctrls:
if PYTHON_LDAP_24:
cookie = pctrls[0].cookie
if cookie:
lc.cookie = cookie
else:
is_last_page = True
else:
cookie = pctrls[0].controlValue[1]
if cookie:
lc.controlValue[1] = cookie
else:
is_last_page = True
else:
is_last_page = True
logger.warn("Server ignores paged results control (RFC 2696).")
return results