简体   繁体   English

python ldap中的身份验证

[英]Authentication in python ldap


I have an ldap server who I connect to using `con = ldap.initialize(server)` and I bind to the server using `con.simple_bind_s(bind_dn, bind_password)`. 我有一个 ldap 服务器,我使用 `con = ldap.initialize(server)` 连接到它,我使用 `con.simple_bind_s(bind_dn, bind_password)` 绑定到服务器。

Now I want a authenticate a user using this ldap connection using his username and password which is different from the bind username and password.现在我想要使用这个 ldap 连接使用他的用户名和密码对用户进行身份验证,这与绑定用户名和密码不同。 I searched a lot but didn't get any concrete answer.我搜索了很多,但没有得到任何具体的答案。

Any help is appreciated.Thanks.任何帮助表示赞赏。谢谢。

 con.simple_bind_s(POST[bind_dn], POST[bind_password])

Can be used for both admin and users, something like this:可用于管理员和用户,如下所示:

 con.simple_bind_s(uid=1000,ou=people,o=org, password)
 con.simple_bind_s(cn=Directory Manager, password)

In general, you can find ready to use modules in python that allow the management for users session using the same priciple, ceck this: https://turbogears.readthedocs.io/en/latest/cookbook/ldap-auth.html一般来说,您可以在 python 中找到允许使用相同原则管理用户会话的准备使用模块,请查看: https ://turbogears.readthedocs.io/en/latest/cookbook/ldap-auth.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM