Skip to content

xhochy/ldapom

 
 

Repository files navigation

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

About

A simple ldap object mapper for python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%