
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
django-ldapdb-pyldap
Advanced tools
django-ldapdb - support for django models over LDAP
Copyright (c) 2009-2011, Bolloré Telecom
Copyright (c) 2013, Jeremy Lainé
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 straightforward, 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, 1.7.x or 1.8.x.
django-ldapdb is distributed under the BSD license, see the LICENSE file for details. See AUTHORS file for a full list of contributors.
Add the following to your settings.py:
DATABASES = {
...
'ldap': {
'ENGINE': 'ldapdb.backends.ldap',
'NAME': 'ldap://ldap.nodomain.org/',
'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 models.py:
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):
return self.name
def __unicode__(self):
return self.name
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.
FAQs
An LDAP database backend for Django
We found that django-ldapdb-pyldap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.