0

我正在使用 pyldap 连接到 AD 服务器 pyldap 提供了两个函数 bind_s() 和 simple_bind_s() 任何人都可以向我解释何时使用 bind_s() 和 simple_bind_s() 以及哪个最好。

4

1 回答 1

1

simple_bind_s()可以进行简单的 LDAP 身份验证或 Kerberos 身份验证。但是,bind_s()只能进行 LDAP 身份验证以形成与 Active Directory 服务器的连接。

我最喜欢 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_ctrls

绑定_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)
于 2017-11-17T06:33:14.957 回答