更新时间:2023-12-04 21:54:22
转到您的Django项目文件夹,并使用
Go to your Django project folder and Start the python interpreter with
python manage.py shell
然后执行
from django_auth_ldap.backend import LDAPBackend
ldapobj = LDAPBackend()
user = ldapobj.populate_user(<LDAP username of an existing user>)
user.is_anonymous()
如果最后一个函数调用返回false,那么您的LDAP认证模块按预期工作。
if the last function call returns false then it your LDAP auth module works as expected.
编辑:
运行Python解释器如上,
Run the Python interpreter as above and,
import ldap
server = 'ldap://<your server ip>'
user_dn = '<dn for a known user>'
password = '<his or her password>'
con = ldap.initialize(server)
con.simple_bind_s(user_dn, password)
这将返回SERVER_DOWN:{'desc':无法联系LDAP服务器}异常,如果您无法连接到LDAP服务器。
This will return SERVER_DOWN: {'desc': "Can't contact LDAP server"} exception, if you can't connect to the LDAP sever.