Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6707a609ee
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (46 sloc) 1.731 kb
LDAP object mapper
==================
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
OS specific installation
------------------------
The unit tests need the ldap-utils and the openldap server.
=== Gentoo ===
You need to emerge net-nds/openldap and add /usr/lib64/openldap/ to your PATH.
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
Jump to Line
Something went wrong with that request. Please try again.