簡體   English   中英

使用flask_ldap3_login與LDAP進行Flask身份驗證

[英]Flask Authentication with LDAP using flask_ldap3_login

我正在嘗試使用flask_ldap3_login向Active Directory驗證我的Flask應用。 我已經編寫了代碼來檢查與活動目錄的連接:

from flask_ldap3_login import LDAP3LoginManager

config = dict()

config['LDAP_HOST'] = 'my_ldap_host'
config['LDAP_BASE_DN'] = 'dc=internal,dc=com'
config['LDAP_USER_DN'] = 'ou=users'
config['LDAP_GROUP_DN'] = 'ou=groups'
config['LDAP_USER_RDN_ATTR'] = 'cn'
config['LDAP_USER_LOGIN_ATTR'] = 'dn'
config['LDAP_BIND_USER_DN'] = None
config['LDAP_BIND_USER_PASSWORD'] = None


ldap_manager = LDAP3LoginManager()
ldap_manager.init_config(config)


response = ldap_manager.authenticate('username', 'password')
print response.status

當我提供LDAP憑證時,會引發錯誤

   raise LDAPOperationResult(result=result['result'], description=result['description'], dn=result['dn'], message=result['message'], response_type=result['type'])
ldap3.core.exceptions.LDAPOperationsErrorResult: LDAPOperationsErrorResult - 1 - operationsError - None - 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1  - searchResDone - None

有人可以告訴我使用LDAP驗證flask應用程序的正確方法嗎?

您需要提供登錄名和密碼才能訪問LDAP:

app.config['LDAP_BIND_USER_DN'] = 'CN=someUser,CN=Users,DC=domain,DC=local'
app.config['LDAP_BIND_USER_PASSWORD'] = "secretpw"

你得到它的工作? 您的代碼中是否包含這些行? 如果沒有,為什么呢?

login_manager = LoginManager(app) # Flask-Login Manager
ldap_manager = LDAP3LoginManager(app) # Setup a LDAP3 Login Manager

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM