Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python 3 module for accessing LDAP directory servers.

Project Description

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.4 or newer, and LDAPv3.

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).

Requirements for building

  • python3.4-dev or newer
  • libldap2-dev
  • libsasl2-dev
  • libkrb5-dev or heimdal-dev (optional)

Documentation

Documentation is available online with a simple tutorial.

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 asyncio (on Python 3.5 or newer):

import asyncio
import bonsai

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

loop = asyncio.get_event_loop()
loop.run_until_complete(do())

Changelog

Currently, you can read the changelog here.

Contribution

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

Release History

This version
History Node

0.9.1

History Node

0.9.0

History Node

0.8.9

History Node

0.8.8

History Node

0.8.7

History Node

0.8.6

History Node

0.8.5

History Node

0.8.1

History Node

0.8.0

Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
bonsai-0.9.1-cp34-cp34m-win32.whl
(57.4 kB) Copy SHA256 Hash SHA256
cp34 Wheel Dec 3, 2017
bonsai-0.9.1-cp34-cp34m-win_amd64.whl
(62.4 kB) Copy SHA256 Hash SHA256
cp34 Wheel Dec 3, 2017
bonsai-0.9.1-cp35-cp35m-win32.whl
(60.7 kB) Copy SHA256 Hash SHA256
cp35 Wheel Dec 3, 2017
bonsai-0.9.1-cp35-cp35m-win_amd64.whl
(68.0 kB) Copy SHA256 Hash SHA256
cp35 Wheel Dec 3, 2017
bonsai-0.9.1-cp36-cp36m-macosx_10_12_x86_64.whl
(1.3 MB) Copy SHA256 Hash SHA256
cp36 Wheel Dec 3, 2017
bonsai-0.9.1-cp36-cp36m-win32.whl
(58.5 kB) Copy SHA256 Hash SHA256
cp36 Wheel Dec 3, 2017
bonsai-0.9.1-cp36-cp36m-win_amd64.whl
(65.9 kB) Copy SHA256 Hash SHA256
cp36 Wheel Dec 3, 2017
bonsai-0.9.1.tar.gz
(108.0 kB) Copy SHA256 Hash SHA256
Source Dec 3, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting