本文整理汇总了Python中ldapcherry.backend.backendLdap.Backend._connect方法的典型用法代码示例。如果您正苦于以下问题:Python Backend._connect方法的具体用法?Python Backend._connect怎么用?Python Backend._connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ldapcherry.backend.backendLdap.Backend
的用法示例。
在下文中一共展示了Backend._connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testConnectSSL
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
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)
示例2: testConnectStartTLS
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
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)
示例3: testConnectSSLWrongCA
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
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")
示例4: testMissingCA
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
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")
示例5: testLdapUnavaible
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
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")
示例6: testConnect
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import _connect [as 别名]
def testConnect(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
ldap = inv._connect()
ldap.simple_bind_s(inv.binddn, inv.bindpassword)
return True