我使用pyldap连接到AD服务器,pyldap提供了两个函数bind_s()和simple_bind_s(),任何一个函数都可以解释何时使用bind_s()和simple_bind_s(),以及哪个函数最好。
发布于 2017-11-17 06:33:14
simple_bind_s()可以进行简单的LDAP身份验证或Kerberos身份验证。但是,bind_s()只能进行LDAP身份验证以形成与Active服务器的连接。
我更喜欢simple_bind_s(),因为我们需要对应用程序的这两种身份验证支持,但是如果您确定您永远不需要在应用程序中实现/使用kerberos身份验证,那么可以随意选择bind_s()。
以下是相应绑定定义(参考文献)的实现:
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_ctrlsbind_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)https://stackoverflow.com/questions/47344154
复制相似问题