我在用着烧瓶_simpledap https://github.com/admiralobvious/flask-simpleldap并且正在努力获得绑定连接来执行任何有用的操作。
我的 LDAP 服务器是活动目录。
精简后的代码如下所示,几乎与这个例子 https://github.com/admiralobvious/flask-simpleldap/blob/master/examples/basic_auth/app.py:
from flask import Flask
from flask_simpleldap import LDAP
app = Flask(__name__)
app.secret_key = 'super secret key'
app.debug = True
app.config['LDAP_HOST'] = 'my-ldap-host.example.com'
app.config['LDAP_REALM_NAME'] = 'LDAP Authentication'
app.config['LDAP_SCHEMA'] = 'ldaps'
app.config['LDAP_PORT'] = 636
app.config['LDAP_BASE_DN'] = 'dc=example,dc=com'
app.config['LDAP_USERNAME'] = '[email protected] /cdn-cgi/l/email-protection'
app.config['LDAP_PASSWORD'] = 'binduser_pw'
app.config['LDAP_OBJECTS_DN'] = 'distinguishedName'
app.config['LDAP_OPENLDAP'] = False
ldap = LDAP(app)
@app.route('/ldap')
@ldap.basic_auth_required
def ldap_protected():
return 'Welcome, {0}!'.format(g.ldap_username)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True)
运行 Flask 应用程序时,我会收到如下错误:
LDAPException: Operations error
在尝试排除故障时,我进行了修改flask_simpleldap
__init__.py
文件来显示info
以及desc
的错误,在line 274 https://github.com/admiralobvious/flask-simpleldap/blob/master/flask_simpleldap/__init__.py#L274;现在我得到了有关该错误的更多信息:
LDAPException: 000004DC: LdapErr: DSID-0C090752,
comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580
所以,我想我需要理解的是为什么我的初始绑定不起作用......我的方法有问题吗?app.config
?
不确定问题可能是什么......ldapsearch
似乎是在 shell 中工作的:
ldapsearch -x -LLL -E pr=200/noprompt -h my-ldap-host.example.com -D "[email protected] /cdn-cgi/l/email-protection" -w 'binduser_pw' -b "dc=example, dc=com" -s sub "(sAMAccountName=binduser)" | grep distinguishedName
distinguishedName: CN=Bind User,OU=Some_OU,DC=example,DC=com
其他详情:
- 我试过 python2.7 和 3.5,同样的问题
- 森托斯 7.2
- Active Directory 是我的 LDAP 服务器
任何帮助表示赞赏,谢谢。