Reputation: 163
I'm trying to implement LDAP authentication in a test Django project. I think I've done all the configuration correctly (I'm using the django_ldap_auth package) and I want to test the authentication without having to create a whole site with log in etc. Is that possible ? FYI, I'm only doing this as a part of making LDAP the main authentication method at my company, and have to plug the functionality into a large project.
I've tried running the server on localhost and ssh-ing through the terminal, but apparently that only logs me onto my own computer, I think :) (not an experienced Linux user).
Any suggestions ?
Upvotes: 16
Views: 9231
Reputation: 1118
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 LDAPBackend
ldapobj = 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 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)
This will return SERVER_DOWN: {'desc': "Can't contact LDAP server"} exception, if you can't connect to the LDAP sever.
Upvotes: 23