LDAP-Hopper
ldap_hopper
is a small Python3
package that allows you to easily navigate and manipulate an LDAP directory-information-tree(DIT).
It neatly wraps around the standard ldap
package and takes away all the nasty bits and pieces of boiler-plating, while making your code more readable.
Installation
pip install ldap_hopper
Usage
from ldap_hopper import Config, Cursor
config = Config(
server='ldap://localhost',
dn='dc=example.dc=com',
)
root = Cursor(config)
print(root.attrs)
[child for child in root.children]
[sub for sub in root.subtree]
dn = 'ou=crew,dc=example,dc=com'
attrs = {
'objectClass': ['organizationalUnit'],
'ou': ['crew'],
}
cursor = root.add(dn, attrs)
[result for result in root.search('ou=crew')]
from ldap_hopper import Scope
[r for r in root.search('objectClass=*', Scope.onelevel)]
cursor.attrs['description'] = 'Lorem ipsum...'
del cursor.attrs['desciption']
cursor.delete()
Development
git clone github.com:baccenfutter/ldap_hopper.git
cd ldap_hopper
pipenv install --dev
Resources
Source: https://github.com/baccenfutter/ldap_hopper
PyPi : https://pypi.python.org/pypi/ldap_hopper/