https://github.com/UMIACS/ldapper
ldapper — a hassle-free Python LDAP ORM for getting real work done
https://github.com/UMIACS/ldapper
ldap ldap-client ldap-library ldap-manager python python3
Last synced: about 1 year ago
JSON representation
ldapper — a hassle-free Python LDAP ORM for getting real work done
- Host: GitHub
- URL: https://github.com/UMIACS/ldapper
- Owner: UMIACS
- License: lgpl-2.1
- Created: 2019-05-10T03:00:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T00:02:13.000Z (about 6 years ago)
- Last Synced: 2025-04-28T09:03:22.274Z (about 1 year ago)
- Topics: ldap, ldap-client, ldap-library, ldap-manager, python, python3
- Language: Python
- Homepage: https://ldapper.readthedocs.io/
- Size: 155 KB
- Stars: 45
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ldapper
========
[](https://travis-ci.org/UMIACS/ldapper)
[](https://ldapper.readthedocs.io/en/latest/?badge=latest)
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.
Requirements
------------
ldapper requires:
* Python 3.6+
* inflection
Version 0.9.0 was the last to support Python 2.
Usage
-----
```python
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://ldap.example.com'
# 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'
person.save()
person.delete()
from ldapper.query import Q
Person.filter(Q(firstname='Foo') | Q(lastname='Bar'))
```
Documentation
-------------
Available at https://ldapper.readthedocs.io/
Testing
-------
Please see the README.md file in the test directory for information on running unit tests.