當前位置: 首頁>>代碼示例>>Python>>正文


Python backendLdap.Backend類代碼示例

本文整理匯總了Python中ldapcherry.backend.backendLdap.Backend的典型用法代碼示例。如果您正苦於以下問題:Python Backend類的具體用法?Python Backend怎麽用?Python Backend使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Backend類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testConnectSSL

 def testConnectSSL(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
     cfg2['checkcert'] = 'on'
     inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
     ldap = inv._connect()
     ldap.simple_bind_s(inv.binddn, inv.bindpassword)
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例2: testConnectStartTLS

 def testConnectStartTLS(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldap://ldap.ldapcherry.org:390'
     cfg2['checkcert'] = 'off'
     cfg2['starttls'] = 'on'
     cfg2['ca'] = './test/cfg/ca.crt'
     inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
     ldapc = inv._connect()
     ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例3: testDelUserDontExists

 def testDelUserDontExists(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     try:
         inv.del_user(u'test☭')
         inv.del_user(u'test☭')
     except UserDoesntExist:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例4: testLdapUnavaible

 def testLdapUnavaible(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://notaldap:637'
     cfg2['checkcert'] = 'on'
     inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
     try:
         ldapc = inv._connect()
         ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
     except ldap.SERVER_DOWN as e:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例5: testMissingCA

 def testMissingCA(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
     cfg2['checkcert'] = 'on'
     cfg2['ca'] = './test/cfg/not_a_ca.crt'
     try:
         inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
         ldapc = inv._connect()
     except CaFileDontExist as e:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例6: testConnectSSLWrongCA

 def testConnectSSLWrongCA(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
     cfg2['checkcert'] = 'on'
     inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
     ldapc = inv._connect()
     try:
         ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
     except ldap.SERVER_DOWN as e:
         assert e[0]['info'] == 'TLS: hostname does not match CN in peer certificate'
     else:
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例7: testAddUser

 def testAddUser(self):
     try:
         inv.del_user(u'test☭,cn=')
     except:
         pass
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     user = {
     'uid': u'test☭,cn=',
     'sn':  u'test☭',
     'cn':  u'test☭',
     'userPassword': u'test☭',
     'uidNumber': '42',
     'gidNumber': '42',
     'homeDirectory': '/home/test/'
     }
     inv.add_user(user)
     inv.del_user(u'test☭,cn=')
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例8: testAddUserMissingMustattribute

 def testAddUserMissingMustattribute(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     user = {
     'uid': u'test☭',
     'sn':  u'test☭',
     'cn':  u'test☭',
     'userPassword': u'test☭',
     'gidNumber': '42',
     'homeDirectory': '/home/test/'
     }
     try:
         inv.add_user(user)
     except ldap.OBJECT_CLASS_VIOLATION:
         return
     else:
         inv.del_user(u'test☭')
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例9: testModifyUser

 def testModifyUser(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     user = {
     'uid': u'test☭',
     'sn':  u'test☭',
     'cn':  u'test☭',
     'userPassword': u'test☭',
     'uidNumber': '42',
     'gidNumber': '42',
     'homeDirectory': '/home/test/'
     }
     inv.add_user(user)
     inv.set_attrs(u'test☭', {'gecos': 'test2', 'homeDirectory': '/home/test/'})
     inv.del_user(u'test☭')
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例10: testAddDeleteGroups

 def testAddDeleteGroups(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     groups = [
        'cn=hrpeople,ou=Groups,dc=example,dc=org',
        'cn=itpeople,ou=Groups,dc=example,dc=org',
     ]
     inv.add_to_groups(u'jwatsoné', groups)
     ret = inv.get_groups(u'jwatsoné')
     inv.del_from_groups(u'jwatsoné', ['cn=hrpeople,ou=Groups,dc=example,dc=org'])
     inv.del_from_groups(u'jwatsoné', ['cn=hrpeople,ou=Groups,dc=example,dc=org'])
     assert ret == ['cn=itpeople,ou=Groups,dc=example,dc=org', 'cn=hrpeople,ou=Groups,dc=example,dc=org']
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:11,代碼來源:test_BackendLdap.py

示例11: testAddUserDuplicate

 def testAddUserDuplicate(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     user = {
     'uid': u'test☭',
     'sn':  u'test☭',
     'cn':  u'test☭',
     'uidNumber': '42',
     'userPassword': u'test☭',
     'gidNumber': '42',
     'homeDirectory': '/home/test/'
     }
     try:
         inv.add_user(user)
         inv.add_user(user)
     except UserAlreadyExists:
         inv.del_user(u'test☭')
         return
     else:
         inv.del_user(u'test☭')
         raise AssertionError("expected an exception")
開發者ID:,項目名稱:,代碼行數:20,代碼來源:

示例12: syslog_error

'dn_user_attr'          : 'uid',
'group_attr.uniqMember' : "%(dn)s",
'group_attr.memberUid'  : "%(uid)s",

}

def syslog_error(msg='', context='',
        severity=logging.INFO, traceback=False):
    pass

cherrypy.log.error = syslog_error
attr = ['shéll', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword', 'givenName', 'email', 'sn']

cherrypy.log.error = syslog_error

inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
print inv.get_user('jwatson')
print inv.get_groups('jwatson')
print inv.search('smit')
user = {
'uid': 'test',
'sn':  'test',
'cn':  'test',
'userPassword': 'test',
'uidNumber': '42',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
inv.add_user(user)
print inv.get_user('test')
print inv.get_groups('test')
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:31,代碼來源:debug_ldapbackend.py

示例13: testAuthFailure

 def testAuthFailure(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     res = inv.auth('notauser', 'password') or inv.auth(u'jwatsoné', 'notapasswordé')
     assert res == False
開發者ID:,項目名稱:,代碼行數:4,代碼來源:

示例14: testAuthSuccess

 def testAuthSuccess(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     ret = inv.auth(u'jwatsoné', u'passwordwatsoné')
     assert ret == True
開發者ID:,項目名稱:,代碼行數:4,代碼來源:

示例15: testGetUser

 def testGetUser(self):
     inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
     ret = inv.get_user(u'jwatsoné')
     expected = {'uid': u'jwatsoné', 'cn': 'John Watson', 'sn': 'watson'}
     assert ret == expected
開發者ID:,項目名稱:,代碼行數:5,代碼來源:


注:本文中的ldapcherry.backend.backendLdap.Backend類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。