Skip to main content

A django Active Directory group management abstraction that uses python-ldap as a backend for cross-platform compatability.

Project description

Version:
1.0.0
Dependencies:

Python 2.7, Django 1.5.2+

Home page:

https://bitbucket.org/alex_kavanaugh/ldap-groups

Author:

Alex Kavanaugh <kavanaugh.development@outlook.com>

License:

GNU LGPL (http://www.gnu.org/licenses/lgpl.html)

Installation

Run pip install ldap-groups

Add ldap-groups to INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'ldap_groups',
    ...
)

Settings

There are a few settings that must be configured before ldap-groups will run.

Mandatory

LDAP_GROUPS_SERVER_URI - The ldap server’s uri, e.g. ‘ldap://example.comLDAP_GROUPS_BASE_DN - The base search dn, e.g. ‘DC=example,DC=com’

Optional

LDAP_GROUPS_BIND_DN - The bind user’s DN LDAP_GROUPS_BIND_PASSWORD - The bind user’s password

NOTE: while a bind user is optional, many servers’ security settings will deny anonymous access.

LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE - The attribute by which to search when looking up users (should be unique). Defaults to 'sAMAccountName'. LDAP_GROUPS_ATTRIBUTE_LIST - A list of attributes returned for each member while pulling group members. An empty list should return all attributes. Defaults to ['displayName', 'sAMAccountName', 'distinguishedName'].

Usage

In its current state, ldap-groups can perform three functions:

  • Add a member to a group

  • Remove a member from a group

  • Get all members of a group (and their attributes) [only retrieves user object classes at this point]

An ADGroup instance only requires one argument to function: a group’s distinguished name. Once the ADGroup is instantiated, the rest is fairly simple:

from ldap_groups import ADGroup

GROUP_DN = "ou=users,dc=example,dc=com"
ACCOUNT_NAME = "jdoe"

class ADGroupModifier(object):

    def __init__(self):
        self.ad_group_instance = ADGroup(GROUP_DN)

    def add_member(self):
        self.ad_group_instance.add_member(ACCOUNT_NAME)

    def remove_member(self):
        self.ad_group_instance.remove_member(ACCOUNT_NAME)

    def get_group_member_info(self):
        return self.ad_group_instance.get_member_info()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ldap-groups-1.0.0.tar.gz (18.3 kB view details)

Uploaded Source

File details

Details for the file ldap-groups-1.0.0.tar.gz.

File metadata

  • Download URL: ldap-groups-1.0.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ldap-groups-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b939c877d313e1b3005223bc2162ca1f20977ca52b59682b540b7a8191ebbca9
MD5 ad882c646e852358cac1abf894f36c99
BLAKE2b-256 5f603dcd69f2658f7492e9ad120751e57ed70a87bb62acc9c85722bbdb860c16

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page