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)
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
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)
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])
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)
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)
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)
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)
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
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)
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)
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
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