Skip to main content

Module for Python 3 to access LDAP directory servers.

Project description

PyPI Version Build Status Coverage Status Documentation Status GitHub License

This is a module for handling LDAP operations in Python. Uses libldap2 on Unix platforms and WinLDAP on Microsoft Windows. LDAP entries are mapped to a special Python case-insensitive dictionary, tracking the changes of the dictionary to modify the entry on the server easily.

Supports only Python 3.3 or newer, and LDAPv3.

Requirements for building

  • python3.3-dev or newer

  • libldap2-dev

  • libsasl2-dev

  • libkrb5-dev or heimdal-dev (optional)

Features

  • Uses LDAP libraries (OpenLDAP and WinLDAP) written in C for faster processing.

  • Simple pythonic design.

  • Implements an own dictionary-like object for mapping LDAP entries that makes easier to add and modify them.

  • Works with various asynchronous library (like asyncio, gevent).

Example

Simple search and modify:

import bonsai

client = bonsai.LDAPClient("ldap://localhost")
client.set_credentials("SIMPLE", ("cn=admin,dc=bonsai,dc=test", "secret"))
with client.connect() as conn:
    res = conn.search("ou=nerdherd,dc=bonsai,dc=test", 2, "(cn=chuck)")
    res[0]['givenname'] = "Charles"
    res[0]['sn'] = "Carmichael"
    res[0].modify()

Using with asnycio:

import asyncio
import bonsai

@asyncio.coroutine
def do():
    client = bonsai.LDAPClient("ldap://localhost")
    client.set_credentials("DIGEST-MD5", ("admin", "secret", None, None))
    with (yield from client.connect(async=True)) as conn:
        res = yield from conn.search("ou=nerdherd,dc=bonsai,dc=test", 2)
        print(res)
        who = yield from conn.whoami()
        print(who)

Documentation

Documentation is available online with a simple tutorial.

Changelog

Currently, you can read the changelog here.

Contribution

Any contributions and advices are welcome. Please report any issues at the GitHub page.

Project details


Download files

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

Source Distributions

bonsai-0.8.5.zip (115.0 kB view hashes)

Uploaded Source

bonsai-0.8.5.tar.gz (88.5 kB view hashes)

Uploaded Source

Built Distributions

bonsai-0.8.5.win-amd64-py3.5.msi (294.9 kB view hashes)

Uploaded Source

bonsai-0.8.5.win-amd64-py3.4.msi (143.4 kB view hashes)

Uploaded Source

bonsai-0.8.5.win32-py3.5.msi (139.3 kB view hashes)

Uploaded Source

bonsai-0.8.5.win32-py3.4.msi (135.2 kB view hashes)

Uploaded Source

bonsai-0.8.5-cp35-none-win_amd64.whl (203.2 kB view hashes)

Uploaded CPython 3.5 Windows x86-64

bonsai-0.8.5-cp35-cp35m-win32.whl (48.0 kB view hashes)

Uploaded CPython 3.5m Windows x86

bonsai-0.8.5-cp35-cp35m-macosx_10_11_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.5m macOS 10.11+ x86-64

bonsai-0.8.5-cp34-none-win_amd64.whl (51.6 kB view hashes)

Uploaded CPython 3.4 Windows x86-64

bonsai-0.8.5-cp34-none-win32.whl (46.3 kB view hashes)

Uploaded CPython 3.4 Windows x86

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