Skip to main content

LDAP ORM for Python

Project description


Build Status Documentation Status

ldapper is a hassle-free Python LDAP ORM for getting real work done.

It extends the robust capabilities of python-ldap and augments it with higher-level interfaces to define your schema. Listing and fetching all your LDAP objects is easy and straightforward. Modifications and validation can be made with assurance using ldapper.


ldapper requires:

  • Python 3.6+
  • inflection

Version 0.9.0 was the last to support Python 2.


from ldapper.connection import BaseConnection
from ldapper.ldapnode import LDAPNode
from ldapper import fields

# define a connection
class Connection(BaseConnection):
    BASE_DN = 'dc=example,dc=com'
    URI = 'ldaps://'

# define a common LDAPNode that holds the connection class you defined
class BaseModel(LDAPNode):
    connection = Connection

# define a class to represent people
class Person(BaseModel):
    uid = fields.StringField('uid', primary=True)
    uidnumber = fields.IntegerField('uidNumber')
    firstname = fields.StringField('givenName')
    lastname = fields.StringField('sn')
    email_addresses = fields.ListField('mailLocalAddress')
    photo = fields.BinaryField('jpegPhoto', optional=True)

    class Meta:
        objectclasses = ['top', 'inetOrgPerson', 'inetLocalMailRecipient']
        dn_format = 'uid=%(uid)s,ou=people'
        primary_dnprefix = 'ou=people'
        secondary_dnprefix = 'ou=people'
        identifying_attrs = ['uid']
        searchable_fields = [
'uid', 'uidNumber', 'givenName', 'sn', 'mailLocalAddress']

# use the Person class
person = Person.fetch('liam')
person.displayname = 'Chuck Yeager'

from ldapper.query import Q
Person.filter(Q(firstname='Foo') | Q(lastname='Bar'))


Available at


Please see the file in the test directory for information on running unit tests.

Download files

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

Files for ldapper, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size ldapper-1.0.3-py3-none-any.whl (31.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ldapper-1.0.3.tar.gz (28.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page