参考flask_simpleldap模块的文档: https://github.com/alexferl/f...

从上面github下载代码,放到项目中

此处注释可以查看其他人的用户名密码 “”“慎重不要外传”“”
from flask import Flask, g
from flask_simpleldap import LDAP
app = Flask(__name__)
app.config["LDAP_HOST"] = "10.x1.1xx.11" # defaults to localhost
app.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_required
def index():
return "Welcome, {0}!".format(g.ldap_username)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=9000)


**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。