Skip to main content

Simple access to LDAP Directory Information Tree.

Project description

===========
LDAP-Hopper
===========

LDAP-Hopper is a simplistic Python binding for accessing an LDAP Directory
Information Tree(DIT).

#!/usr/bin/env python
from ldap_hopper import ObjectNode

# access the root-node
server = 'localhost'
base_dn = 'dc=example,dc=org'
bind_dn = 'cn=admin,dc=example,dc=org'
bind_pw = 'secret'
root = ObjectNode(server, base_dn, bind_dn, bind_pw)

# show attributes of root-node
print root.get_attrs()

# get childs of root
print root.get_childs()
print root.get_childs(by_attr='ou=*')

# get subtree of root
print root.get_subs()
print root.get_subs(by_attr='ou=*')

# add child node
attrs_1 = {
'objectClass': ['organizationalUnit'],
'ou': ['node_1'],
}
attrs_2 = {
'objectClass': ['organizationalUnit'],
'ou': ['node_2'],
}
node_1 = root.add_child('ou=node_1,dc=example,dc=org', attrs)
node_2 = root.add_child('ou=node_2', attrs) # will auto-expand self.dn
print node_1, node_2

# search for an object
node_1 = root.search('ou', 'node_1') # no scope defaults to onelevel
node_2 = root.search('ou', 'node_2', ldap.SCOPE_SUBTREE) # default can be overwritten
print node_1, node_2

# delete child node
root.del_child('ou=node_1,dc=example,dc=org')
root.del_child('ou=node_2') # shortcut also allowed


=========
Resources
=========

Source: https://github.com/baccenfutter/ldap_hopper
PyPi : https://pypi.python.org/pypi/LDAP-Hopper/

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

LDAP-Hopper-0.2.2.tar.gz (3.6 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