django-ldapdb is an LDAP database backend for Django, allowing to manipulate LDAP entries through Django models.
It supports most of the same APIs as a Django model:
MyModel.objects.create()
MyModel.objects.filter(x=1, y__contains=2)
Full admin support and browsing
django-ldapdb supports Django versions 1.7 to 1.9, and Python 2.7/3.4/3.5.
Using django-ldapdb
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-ldapdb-0.6.0.tar.gz.
File metadata
- Download URL: django-ldapdb-0.6.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d45fe8bc747125f5353d05c518e2e8e00a88b8f2b6444cc74b3ed126aba7cef5
|
|
| MD5 |
16f5679dcd3c04d0ca745de774868c12
|
|
| BLAKE2b-256 |
572a0b24821f20ac7b0a3942efc6b371aa6b1ff752c1c686479d992f12147158
|
File details
Details for the file django_ldapdb-0.6.0-py3-none-any.whl.
File metadata
- Download URL: django_ldapdb-0.6.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98b3612ff73abf1d69a0526e5893011edec5943cc1def8770e6192ee132eccc2
|
|
| MD5 |
67d35998162438c52a24bbca6239a92f
|
|
| BLAKE2b-256 |
38e43191a2cf0a25e25db268954f3af38fda1b050b66cb6aa0c15231673dae8e
|