当前位置: 首页>>代码示例>>Python>>正文


Python ldap.controls方法代码示例

本文整理汇总了Python中ldap.controls方法的典型用法代码示例。如果您正苦于以下问题:Python ldap.controls方法的具体用法?Python ldap.controls怎么用?Python ldap.controls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ldap的用法示例。


在下文中一共展示了ldap.controls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ldap_query

# 需要导入模块: import ldap [as 别名]
# 或者: from ldap import controls [as 别名]
def ldap_query(self,l, base_dn, subtree, objectFilter, attrs):
		ldap_control = ldap.controls.SimplePagedResultsControl (True, size=1000, cookie='' )
		results = []
		while True:
			msgid = l.search_ext (base_dn, subtree, objectFilter, attrs, serverctrls=[ldap_control] )
			rtype, rawResults, id, server_controls = l.result3 ( msgid )
			results += rawResults
			page_controls = [c for c in server_controls if c.controlType == ldap.controls.SimplePagedResultsControl.controlType]
			if page_controls:
				cookie = page_controls[0].cookie
			if not cookie:
				break
			else:
				ldap_control.cookie = cookie
		return results 
开发者ID:Tylous,项目名称:Vibe,代码行数:17,代码来源:AD.py

示例2: at_least_one_user_exists

# 需要导入模块: import ldap [as 别名]
# 或者: from ldap import controls [as 别名]
def at_least_one_user_exists(self):
        logger.debug("Checking if any users exist in LDAP")
        try:
            with self._ldap.get_connection():
                pass
        except ldap.INVALID_CREDENTIALS:
            return (None, "LDAP Admin dn or password is invalid")

        has_pagination = not self._force_no_pagination
        with self._ldap.get_connection() as conn:
            for user_search_dn in self._user_dns:
                search_flt = "(objectClass=*)"
                search_flt = self._add_user_filter(search_flt)

                lc = ldap.controls.libldap.SimplePagedResultsControl(
                    criticality=True, size=1, cookie=""
                )
                try:
                    if has_pagination:
                        msgid = conn.search_ext(
                            user_search_dn, ldap.SCOPE_SUBTREE, search_flt, serverctrls=[lc]
                        )
                        _, rdata, _, serverctrls = conn.result3(msgid)
                    else:
                        msgid = conn.search(user_search_dn, ldap.SCOPE_SUBTREE, search_flt)
                        _, rdata = conn.result(msgid)

                    for entry in rdata:  # Handles both lists and iterators.
                        return (True, None)

                except ldap.LDAPError as lde:
                    return (False, str(lde) or "Could not find DN %s" % user_search_dn)

        return (False, None) 
开发者ID:quay,项目名称:quay,代码行数:36,代码来源:externalldap.py


注:本文中的ldap.controls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。