Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

django-ldapdb, an LDAP database backend for Django

branch: master

Merge pull request #40 from rbarrois/modernize

tests: Use assertEqual instead of outdated assertEquals.
latest commit ebf6e67ec2
Jeremy Lainé authored April 20, 2014
Octocat-spinner-32 examples revert previous commit January 27, 2014
Octocat-spinner-32 ldapdb Merge pull request #40 from rbarrois/modernize April 20, 2014
Octocat-spinner-32 .addcopyright update copyright notice September 03, 2013
Octocat-spinner-32 .gitignore ignore egg files November 16, 2013
Octocat-spinner-32 .travis.yml test against django 1.7a1 January 27, 2014
Octocat-spinner-32 AUTHORS update my e-mail address November 16, 2013
Octocat-spinner-32 LICENSE update copyright notice September 03, 2013
Octocat-spinner-32 mention django 1.7 compatibility January 27, 2014
Octocat-spinner-32 import to git June 04, 2013
Octocat-spinner-32 modernise November 16, 2013
Octocat-spinner-32 simplify settings January 27, 2014
Octocat-spinner-32 bump version to 0.3.0 January 27, 2014
Octocat-spinner-32 fix django 1.2 and 1.3 compatibility September 05, 2013

django-ldapdb - support for django models over LDAP
Copyright (c) 2009-2011, Bolloré Telecom
Copyright (c) 2013, Jeremy Lainé

Build Status


django-ldapdb is an LDAP database backend for Django. It allows you to manipulate LDAP entries using Django's models. Declaring models using the LDAP backend is very staightforward, you simply inherit from ldapdb.models.Model and declare the fields in the same way as for regular models. You can even edit the LDAP entries using Django's admin interface.

django-ldapdb requires Django version 1.2.x, 1.3.x, 1.4.x, 1.5.x, 1.6.x or 1.7.x.

django-ldapdb is distributed under the BSD license, see the LICENSE file for details. See AUTHORS file for a full list of contributors.

Using django-ldapdb

Add the following to your

    'ldap': {
        'ENGINE': 'ldapdb.backends.ldap',
        'NAME': 'ldap://',
        'USER': 'cn=admin,dc=nodomain,dc=org',
        'PASSWORD': 'some_secret_password',
DATABASE_ROUTERS = ['ldapdb.router.Router']

If you want to access posixGroup entries in your application, you can add something like this to your

from ldapdb.models.fields import CharField, IntegerField, ListField
import ldapdb.models

class LdapGroup(ldapdb.models.Model):
    Class for representing an LDAP group entry.
    # LDAP meta-data
    base_dn = "ou=groups,dc=nodomain,dc=org"
    object_classes = ['posixGroup']

    # posixGroup attributes
    gid = IntegerField(db_column='gidNumber', unique=True)
    name = CharField(db_column='cn', max_length=200, primary_key=True)
    members = ListField(db_column='memberUid')

    def __str__(self):

    def __unicode__(self):

Important note : you must declare an attribute to be used as the primary key. This attribute will play a special role, as it will be used to build the Relative Distinguished Name of the entry. For instance in the example above, a group whose cn is foo will have the DN cn=foo,ou=groups,dc=nodomain,dc=org.

Something went wrong with that request. Please try again.