This document will include the author's entire notes on installing and configuring ldap for django.
Create a directory in /opt:
Create a virtualenv in that directory:
Make sure that you also source the directory before running pip commands. i.e.:
pip install django
Here you have two options. Either install with pip or install using the package manager.
Installing with package-manager:sudo apt-get install python-ldap
Install with pip
First install dependencies:sudo apt-get install libldap2-dev sudo apt-get install libsasl2-dev
Then you should be able to install with pip:pip install python-ldap
You may also have to install python-dev, if you haven't already
- Install django-auth-ldap
Here again you have two options. Either install with pip of install using your package manager.
Installing with package-manager:sudo apt-get install python-django-auth-ldap
You may also want the docs package:sudo apt-get install python-django-auth-ldap-doc
Install with pip:pip install django-auth-ldap
If you are unhappy with the quantity of logs produced by the ldap module patch the file "venv0/lib/python2.7/site-packages/ldap/ldapobject.py," in my expierence logging before and after line 100 works magically.
For example changing:
result = func(*args,**kwargs)
import logging logger = logging.getLogger('django_auth_ldap') logger.info("in Func: %s Args: %s, Kw: %s" % (str(func), str(args), str(kwargs))) result = func(*args,**kwargs) logger.info("out Func: %s Result: %s" % (str(func), str(result)))
Please remember to see logs generated by the previous lines in django, you must also set up logging for "django_auth_ldap" in the settings file.
Active directory Error 49 Codes
Quick Guide to Error code 49 on AD systems
|525||user not found|
|530||not permitted to logon at this time|
|531||not permitted to logon at this workstation|
|773||user must reset password|
|775||user account locked|