pyldap AD 身份验证 bind_s 与 simple_bind_s
pyldap AD authentication bind_s vs simple_bind_s
我正在使用 pyldap 连接到 AD 服务器
pyldap 提供了两个函数 bind_s() 和 simple_bind_s()
谁能解释一下什么时候使用 bind_s() 和 simple_bind_s() 以及哪个最好。
simple_bind_s()可以做简单的LDAP认证或者Kerberos认证。但是,bind_s() 只能进行 LDAP 身份验证以与 Active Directory 服务器建立连接。
我最喜欢 simple_bind_s() 因为我们需要对应用程序的身份验证支持,但如果您确定您永远不需要 implement/use kerberos 身份验证在您的应用程序中然后随意选择 bind_s().
以下是各个绑定定义的实现(Reference):
simple_bind_s():
def simple_bind_s(self,who='',cred='',serverctrls=None,clientctrls=None):
"""
simple_bind_s([who='' [,cred='']]) -> 4-tuple
"""
msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
return resp_type, resp_data, resp_msgid, resp_ctrls
bind_s():
def bind_s(self,who,cred,method=ldap.AUTH_SIMPLE):
"""
bind_s(who, cred, method) -> None
"""
msgid = self.bind(who,cred,method)
return self.result(msgid,all=1,timeout=self.timeout)
我正在使用 pyldap 连接到 AD 服务器 pyldap 提供了两个函数 bind_s() 和 simple_bind_s() 谁能解释一下什么时候使用 bind_s() 和 simple_bind_s() 以及哪个最好。
simple_bind_s()可以做简单的LDAP认证或者Kerberos认证。但是,bind_s() 只能进行 LDAP 身份验证以与 Active Directory 服务器建立连接。
我最喜欢 simple_bind_s() 因为我们需要对应用程序的身份验证支持,但如果您确定您永远不需要 implement/use kerberos 身份验证在您的应用程序中然后随意选择 bind_s().
以下是各个绑定定义的实现(Reference):
simple_bind_s():
def simple_bind_s(self,who='',cred='',serverctrls=None,clientctrls=None):
"""
simple_bind_s([who='' [,cred='']]) -> 4-tuple
"""
msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
return resp_type, resp_data, resp_msgid, resp_ctrls
bind_s():
def bind_s(self,who,cred,method=ldap.AUTH_SIMPLE):
"""
bind_s(who, cred, method) -> None
"""
msgid = self.bind(who,cred,method)
return self.result(msgid,all=1,timeout=self.timeout)