参考flask_simpleldap模块的文档: https://github.com/alexferl/f...
从下面github下载代码,放到我的项目中
此处正文能够查看其他人的用户名明码 “”“谨慎不要外传”“”
from flask import Flask, gfrom flask_simpleldap import LDAPapp = Flask(__name__)app.config["LDAP_HOST"] = "10.x1.1xx.11" # defaults to localhostapp.config["LDAP_BASE_DN"] = "OU=xxhu-sh,DC=xiaxxxhu,DC=sh"app.config["LDAP_USERNAME"] = "CN=ixxp,OU=Sxxxount,DC=xxxxxu,DC=sh"app.config["LDAP_PASSWORD"] = "uxxxP"ldap = LDAP(app)@app.route("/")@ldap.basic_auth_requireddef index(): return "Welcome, {0}!".format(g.ldap_username)if __name__ == "__main__": app.run(host="0.0.0.0", port=9000)