示例#1
0
 def test_search_sizelimit(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     with self.assertRaises(LDAPError) as cm:
         ld.search(self.env['suffix'], LDAP_SCOPE_SUB, sizelimit=1)
     self.assertEqual(cm.exception.return_code,
                      4)  # Size limit exceeded (4)
示例#2
0
def ldapsearch_gid(uri, bind_dn, bind_pass, base_dn):
    ldap = LDAP(URI)
    ldap.bind(BIND_DN, BIND_PASS)
    ldap.unbind()
    result = ldap.search(BASE_DN, LDAP_SCOPE_SUB,
                         '(uidNumber=*)', ['gidNumber'])
    return result
示例#3
0
 def test_search_attributes_attrs_only(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'],
                   LDAP_SCOPE_SUB,
                   filter='cn=auth',
                   attrsonly=True)
     self.assertEqual(len(r[0]['cn']), 0)
示例#4
0
 def test_search_attributes(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'],
                   LDAP_SCOPE_SUB,
                   filter='cn=auth',
                   attributes=['cn'])
     self.assertIn('cn', r[0])
     self.assertNotIn('objectClass', r[0])
示例#5
0
 def test_rename_oldrdn(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     (newrdn, newparent) = self.env['modify_user'].split(',', 1)
     newrdn += '-newrdn'
     ld.rename(self.env['modify_user'], newrdn, newparent, deleteoldrdn=False, async=True)
     time.sleep(0.3)
     entry = ld.search('%s,%s' % (newrdn, newparent), attributes=['uid'])[0]
     self.assertEqual(len(entry['uid']), 2)
     # re-rename
     ld.rename('%s,%s' % (newrdn, newparent), self.env['modify_user'].split(',', 1)[0], newparent)
示例#6
0
 def test_rename_oldrdn(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     (newrdn, newparent) = self.env['target_user'].split(',', 1)
     newrdn += '-newrdn'
     ld.rename(self.env['target_user'],
               newrdn,
               newparent,
               deleteoldrdn=False,
               async=True)
     time.sleep(0.3)
     entry = ld.search('%s,%s' % (newrdn, newparent), attributes=['uid'])[0]
     self.assertEqual(len(entry['uid']), 2)
     # re-rename
     ld.rename('%s,%s' % (newrdn, newparent),
               self.env['target_user'].split(',', 1)[0], newparent)
示例#7
0
 def test_search_filter(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'], LDAP_SCOPE_SUB, filter='cn=auth')
     self.assertEqual(len(r), 1)
示例#8
0
 def test_search_base(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     self.assertEqual(len(ld.search(self.env['suffix'])), 1)
示例#9
0
def ldapsearch_uid(uri, bind_dn, bind_pass, base_dn):
    ldap = LDAP(URI)
    ldap.bind(BIND_DN, BIND_PASS)
    ldap.unbind()
    result = ldap.search(BASE_DN, LDAP_SCOPE_SUB, 'cn=miyabi', ['cn'])
    return result
示例#10
0
 def test_search_sizelimit(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     with self.assertRaises(LDAPError) as cm:
         r = ld.search(self.env['suffix'], LDAP_SCOPE_SUB, sizelimit=1)
     self.assertEqual(cm.exception.return_code, 4)  # Size limit exceeded (4)
示例#11
0
 def test_search_attributes(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'], LDAP_SCOPE_SUB, filter='cn=auth', attrsonly=True)
     self.assertEqual(len(r[0]['cn']), 0)
示例#12
0
 def test_search_attributes(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'], LDAP_SCOPE_SUB, filter='cn=auth', attributes=['cn'])
     self.assertIn('cn', r[0])
     self.assertNotIn('objectClass', r[0])
示例#13
0
 def test_search_filter(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     r = ld.search(self.env['suffix'], LDAP_SCOPE_SUB, filter='cn=auth')
     self.assertEqual(len(r), 1)
示例#14
0
 def test_search_base(self):
     ld = LDAP(self.env['uri_389'])
     ld.bind(self.env['root_dn'], self.env['root_pw'])
     self.assertEqual(len(ld.search(self.env['suffix'])), 1)
示例#15
0
def ldapsearchmiyabi():
    ld = LDAP(URI)
    ld.bind(BIND_DN, BIND_PASS)
    result = ld.search('uid=miyabi2,ou=Users,dc=example,dc=jp', LDAP_SCOPE_SUB,
                       '(&(uid=miyabi2)(ou=Users))')
    return result
示例#16
0
def ldapsearch_ou():
    ldap = LDAP(URI)
    ldap.bind(BIND_DN, BIND_PASS)
    result = ldap.search(BASE_DN, LDAP_SCOPE_SUB, '(|(cn=miyabi)(dc=jp))')
    return result