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

A module that makes simple LDAP usage simple.

Project Description


A small wrapper around the python-ldap library that provides a more Pythonic interface for LDAP server connections, LDAP objects, and the common get and search operations.


Install using pip:

pip install simpleldap


A quick and easy example using simpleldap:

>>> import simpleldap
>>> conn = simpleldap.Connection('')
>>> user = conn.get("uid=myuser")
>>> user.dn
>>> user['cn']
['Joe Smith', 'Joe M. Smith']
>>> user.first('cn')
'Joe Smith'
>>> conn.close()

The Connection object can also be used as a context manager, e.g.:

with simpleldap.Connection('') as conn:
    users ="(&(givenName=Joe)(sn=Smith))")

A common method for authenticating users is to connect to an LDAP server using a service user/account and then attempt a bind operation using the user’s credentials (i.e. DN and password). The authenticate method makes this simple:

with simpleldap.Connection('') as conn:
    is_valid = conn.authenticate('uid=myuser,dc=directory,dc=example,dc=com', 'password')


The authentication method does not perform an unbind and does not bind again using the original connection’s credentials; therefore, any further actions following a successful authenticate call will be performed as the authenticated user.

LDAP also offers a feature to compare an attribute’s value with a given string. This can occasionally be more efficient and expressive than grabbing an entire object from the LDAP store. simpleldap offers a compare method for this feature:

>>> conn = simpleldap.Connection('')
>>> user_dn = 'uid=myuser,dc=directory,dc=example,dc=com'
>>>, 'cn', 'Joe Smith')
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
simpleldap-0.8.tar.gz (8.9 kB) Copy SHA256 Checksum SHA256 Source May 29, 2014

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