Skip to content


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
MIT, so do what you want, but leave the copyright notice in the code
Fork it!
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.
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>
>>> # show surname
<LdapAttribute: sn=O'Niel>
>>> = 'Meier' # change givenname
>>> # 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']
>>> = 'newuser'
>>> = 'newuser'
Search for attributes:
>>> result ='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://', base='dc=example,dc=com', login='cn=admin,dc=example,dc=com', password='admin', cert='/path/to/cert') # doctest: +SKIP
To install development dependencies use
pip install -r dev-requirements.txt
Make sure, openldap is installed then run
Jump to Line
Something went wrong with that request. Please try again.