Introduction
This document will include the author's entire notes on installing and configuring ldap for django.
Installation
Create a directory in /opt:
mkdir /opt/that
Create a virtualenv in that directory:
virtualenv example
Make sure that you also source the directory before running pip commands. i.e.:
source /opt/that/example/bin/activate
Install django:
pip install django
Install python-ldap
Here you have two options. Either install with pip or install using the package manager.
Installing with package-manager:
sudo apt-get install python-ldapInstall with pip
First install dependencies:
sudo apt-get install libldap2-dev sudo apt-get install libsasl2-devThen you should be able to install with pip:
pip install python-ldapYou may also have to install python-dev, if you haven't already
Dependency sources:
- 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-ldapYou may also want the docs package:
sudo apt-get install python-django-auth-ldap-doc
Install with pip:
pip install django-auth-ldap
LDAP Debugging
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)
To:
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
Data | Message |
---|---|
525 | user not found |
52e | invalid credentials |
530 | not permitted to logon at this time |
531 | not permitted to logon at this workstation |
532 | password expired |
533 | account disabled |
701 | account expired |
773 | user must reset password |
775 | user account locked |
source: | https://confluence.atlassian.com/display/CROWD/Active+Directory+LDAP+Errors |
---|