gpt4 book ai didi

python - 使用 flask_ldap3_login 使用 LDAP 进行 Flask 身份验证

转载 作者:行者123 更新时间:2023-12-03 17:01:07 25 4
gpt4 key购买 nike

我正在尝试使用 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"

关于python - 使用 flask_ldap3_login 使用 LDAP 进行 Flask 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38048093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com