Skip to main content

A simple ldap object mapper for python

Project description

This python module provides a simple LDAP object mapper

License

MIT, so do what you want, but leave the copyright notice in the code

Github

Fork it!

https://github.com/HaDiNet/ldapom

Usage

Playing around:

>>> import ldapom
>>> lc = ldapom.LdapConnection(uri='ldap://localhost:1381', base='dc=example,dc=com', login='cn=admin,dc=example,dc=com', password='admin') # doctest: +SKIP
>>> node = lc.get_ldap_node('cn=jack,dc=example,dc=com')
>>> node # just show
<LdapNode: cn=jack,dc=example,dc=com>
>>> node.sn # show surname
<LdapAttribute: sn=O'Niel>
>>> node.sn = 'Meier' # change givenname
>>> node.save() # save all changes
>>> node.delete() # delete

Create a new ldap node:

>>> node2 = lc.new_ldap_node('cn=newuser,dc=example,dc=com')
>>> node2.objectClass = ['person']
>>> node2.cn = 'newuser'
>>> node2.sn = 'newuser'
>>> node2.save()

Search for attributes:

>>> result = lc.search('objectClass=posixAccount')
>>> list(result)
[<LdapNode: cn=daniel,dc=example,dc=com>, <LdapNode: cn=sam,dc=example,dc=com>]

Howto use TLS:

>>> lc = ldapom.LdapConnection(uri='ldaps://your.server.com', base='dc=example,dc=com', login='cn=admin,dc=example,dc=com', password='admin', cert='/path/to/cert') # doctest: +SKIP

Testing

To install development dependencies use

pip install -r dev-requirements.txt

Make sure, openldap is installed then run

python2 tests.py

Project details


Download files

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

Source Distribution

ldapom-0.9.2.tar.gz (6.4 kB view hashes)

Uploaded Source

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