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


Python ldap3.ALL_ATTRIBUTES属性代码示例

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


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

示例1: test_00_wrong_basedn

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_00_wrong_basedn(self):

        s = "(&(cn=*))"
        base = "o=invalid"
        self.c.search(search_base=base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0)

        s = "(!(cn=*))"
        base = "o=invalid"
        self.c.search(search_base=base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0)

        s = "(|(cn=*)(sn=*))"
        base = "o=invalid"
        self.c.search(search_base=base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:24,代码来源:test_mock_ldap3.py

示例2: test_05_simple_and_simple_greater_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_05_simple_and_simple_greater_condition(self):
        dn = "cn=bob,ou=example,o=test"
        s = "(&(oid>=3))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=manager,ou=example,o=test"
        s = "(&(accountExpires>=9223372036854775808))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:20,代码来源:test_mock_ldap3.py

示例3: test_06_simple_and_simple_less_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_06_simple_and_simple_less_condition(self):
        dn = "cn=manager,ou=example,o=test"
        s = "(&(oid<=1))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=alice,ou=example,o=test"
        dn1 = "cn=mini,ou=example,o=test"
        s = "(&(accountExpires<=9223372036854775805))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 2)
        self.assertTrue(self.c.response[0].get("dn") == dn)
        self.assertTrue(self.c.response[1].get("dn") == dn1) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:22,代码来源:test_mock_ldap3.py

示例4: test_10_simple_not_simple_greater_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_10_simple_not_simple_greater_condition(self):
        dn = "cn=manager,ou=example,o=test"
        s = "(!(oid>=2))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=mini,ou=example,o=test"
        s = "(!(accountExpires>=1))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:20,代码来源:test_mock_ldap3.py

示例5: test_11_simple_not_simple_less_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_11_simple_not_simple_less_condition(self):
        dn = "cn=bob,ou=example,o=test"
        s = "(!(oid<=2))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=manager,ou=example,o=test"
        s = "(!(accountExpires<=9223372036854775807))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:20,代码来源:test_mock_ldap3.py

示例6: test_12_multi_not

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_12_multi_not(self):
        dn = "cn=alice,ou=example,o=test"
        dn1 = "cn=bob,ou=example,o=test"
        dn2 = "cn=manager,ou=example,o=test"
        s = "(!(&(sn~=Cooper)(cn=mini)))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 3)
        self.assertTrue(self.c.response[0].get("dn") == dn)
        self.assertTrue(self.c.response[1].get("dn") == dn1)
        self.assertTrue(self.c.response[2].get("dn") == dn2)

        dn = "cn=mini,ou=example,o=test"
        s = "(!(|(cn~=bob)(sn=*le*)(accountExpires>=100)))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:24,代码来源:test_mock_ldap3.py

示例7: test_15_simple_or_simple_greater_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_15_simple_or_simple_greater_condition(self):
        dn = "cn=bob,ou=example,o=test"
        s = "(|(oid>=3))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=manager,ou=example,o=test"
        s = "(|(accountExpires>=9223372036854775808))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:20,代码来源:test_mock_ldap3.py

示例8: test_16_simple_or_simple_less_condition

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_16_simple_or_simple_less_condition(self):
        dn = "cn=manager,ou=example,o=test"
        s = "(|(oid<=1))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn)

        dn = "cn=mini,ou=example,o=test"
        s = "(|(accountExpires<=100))"

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:20,代码来源:test_mock_ldap3.py

示例9: test_25_add_user

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_25_add_user(self):
        dn = "cn=John Smith,ou=example,o=test"
        data = { "sn" : "Smith",
                "cn" : "John Smith",
                "userPassword": "S3cr3t",
                }
        classes = ["top", "inetOrgPerson"]
        s = "(&(cn=John Smith)(objectClass=top))"

        r = self.c.add(dn, classes, data)
        self.assertTrue(r)

        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 1)
        self.assertTrue(self.c.response[0].get("dn") == dn) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:19,代码来源:test_mock_ldap3.py

示例10: run

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def run(self, params={}):
        conn = self.connection.conn
        query = params.get('search_filter')

        query = ADUtils.dn_normalize(query)
        temp_list = ADUtils.dn_escape_and_split(query)
        query_list = [s for s in temp_list if 'DC' in s]
        query = ','.join(query_list)
        escaped_query = ','.join(temp_list)
        escaped_query = escaped_query.replace("\\>=", ">=")
        escaped_query = escaped_query.replace("\\<=", "<=")

        # find pars of `(` `)`
        pairs = ADUtils.find_parentheses_pairs(escaped_query)

        # replace ( and ) when they are part of a name rather than a search parameter
        for key, value in pairs.items():
            tempstring = escaped_query
            if tempstring.find('=', key, value) == -1:
                escaped_query = escaped_query[:value] + '\\29' + escaped_query[value + 1:]
                escaped_query = escaped_query[:key] + '\\28' + escaped_query[key + 1:]
        self.logger.info(f"Escaped query: {escaped_query}")

        conn.search(search_base=params.get('search_base'),
                    search_filter=escaped_query,
                    attributes=[ldap3.ALL_ATTRIBUTES, ldap3.ALL_OPERATIONAL_ATTRIBUTES]
                    )

        result_list_json = conn.response_to_json()
        result_list_object = json.loads(result_list_json)
        entries = result_list_object["entries"]

        for entry in entries:
            if entry.get("dn"):
                entry["dn"] = entry["dn"].replace("\\", "")

            if entry.get("attributes") and entry.get("attributes").get("distinguishedName"):
                entry.get("attributes")["distinguishedName"] = \
                    entry.get("attributes").get("distinguishedName").replace("\\", "")

        return {'results': entries} 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:43,代码来源:action.py

示例11: ldap_query

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def ldap_query(self, query):

        if not self.ldap_enabled:
            return None

        from ldap3 import Server, Connection, SIMPLE, SYNC, ASYNC, SUBTREE, ALL, ALL_ATTRIBUTES
        import json

        try:
            logging.debug("connecting to ldap server {} on port {}".format(self.ldap_server, self.ldap_port))
            with Connection(
                Server(self.ldap_server, port = self.ldap_port, get_info = ALL), 
                auto_bind = True,
                client_strategy = SYNC,
                user=self.ldap_bind_user,
                password=self.ldap_bind_password,
                authentication=SIMPLE, 
                check_names=True) as c:

                logging.debug("running ldap query for ({})".format(query))
                c.search(self.ldap_base_dn, '({})'.format(query), SUBTREE, attributes = ALL_ATTRIBUTES)

                # a little hack to move the result into json
                response = json.loads(c.response_to_json())
                result = c.result

                if len(response['entries']) < 1:
                    return None

                # XXX not sure about the 0 here, I guess only if we only looking for one thing at a time
                return response['entries'][0]['attributes']

        except Exception as e:
            logging.warning("failed ldap query {}: {}".format(query, e))
            return None 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:37,代码来源:__init__.py

示例12: tivoli_ldap_query

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def tivoli_ldap_query(self, query):                                                                                        
        
        if not self.tivoli_ldap_enabled:                                                                                       
            return None
                                                                                                 
        from ldap3 import Server, Connection, SIMPLE, SYNC, ASYNC, SUBTREE, ALL, ALL_ATTRIBUTES                         
        import json                                                                                                     
                                                                                                                        
        try:                                                                                                            
            logging.debug("connecting to tivoli ldap server {} on port {}".format(self.tivoli_server, self.tivoli_ldap_port))           
            with Connection(                                                                                            
                Server(self.tivoli_server, port = self.tivoli_ldap_port , get_info = ALL),                                        
                auto_bind = False,                                                                                       
                client_strategy = SYNC,                                                                                 
                user=self.tivoli_bind_user,                                                                               
                password=self.tivoli_bind_password,                                                                       
                authentication=SIMPLE,                                                                                  
                check_names=True) as c:                                                                                 

                logging.debug("running tivoli ldap query for ({})".format(query))                                             
                c.search(self.tivoli_base_dn, '({})'.format(query), SUBTREE, attributes = ALL_ATTRIBUTES)                

                # a little hack to move the result into json                                                            
                response = json.loads(c.response_to_json())                                                             
                result = c.result                                                                                       

                if len(response['entries']) < 1:                                                                        
                    return None                                                                                         
                                                                                                                        
                # XXX not sure about the 0 here, I guess only if we only looking for one thing at a time                
                return response['entries'][0]['attributes']                                                             

        except Exception as e:                                                                                          
            logging.warning("failed tivoli ldap query {}: {}".format(query, e))                                           
            return None 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:37,代码来源:__init__.py

示例13: test_01_invalid_attribute

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_01_invalid_attribute(self):

        s = "(&(invalid=*))"
        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:9,代码来源:test_mock_ldap3.py

示例14: test_02_invalid_search_string

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_02_invalid_search_string(self):

        s = "(&cn=*))"
        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0)

        s = "(&(cn=*)sn=*)"
        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 0) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:15,代码来源:test_mock_ldap3.py

示例15: test_18_simple_and_multi_value_attribute

# 需要导入模块: import ldap3 [as 别名]
# 或者: from ldap3 import ALL_ATTRIBUTES [as 别名]
def test_18_simple_and_multi_value_attribute(self):

        dn1 = "cn=alice,ou=example,o=test"
        dn2 = "cn=mini,ou=example,o=test"
        s = "(&(mobile=45678))"
        self.c.search(search_base=self.base, search_filter=s, search_scope=ldap3.SUBTREE,
                attributes = ldap3.ALL_ATTRIBUTES, paged_size = 5)

        self.assertTrue(len(self.c.response) == 2)
        self.assertTrue(self.c.response[0].get("dn") == dn1)
        self.assertTrue(self.c.response[1].get("dn") == dn2) 
开发者ID:privacyidea,项目名称:privacyidea,代码行数:13,代码来源:test_mock_ldap3.py


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