[英]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(),因為我們同時需要對應用程序的身份驗證支持,但是如果您確定永遠不需要在應用程序中實現/使用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
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.