Coder Social home page Coder Social logo

chronossc / django-ldapdb Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 6.0 430 KB

A clone of django-ldapdb ajusted to work with Active Directory

Home Page: http://opensource.bolloretelecom.eu/projects/django-ldapdb/

License: BSD 2-Clause "Simplified" License

Python 100.00%

django-ldapdb's Introduction

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

Build Status

About

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.

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.

django-ldapdb's People

Contributors

chronossc avatar g1itch avatar jlaine avatar mgorny avatar nandoflorestan avatar rbarrois avatar xaroth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.