Testing authentication in Django Testing authentication in Django django django

Testing authentication in Django


Go to your Django project folder and Start the python interpreter with

python manage.py shell

and then do,

from django_auth_ldap.backend import LDAPBackendldapobj = LDAPBackend()user = ldapobj.populate_user(<LDAP username of an existing user>)user.is_anonymous()

if the last function call returns false then it your LDAP auth module works as expected.

edit:

Run the Python interpreter as above and,

import ldapserver = '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)

This will return SERVER_DOWN: {'desc': "Can't contact LDAP server"} exception, if you can't connect to the LDAP sever.