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.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file LDAP-Hopper-0.2.4.tar.gz.

File metadata

  • Download URL: LDAP-Hopper-0.2.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for LDAP-Hopper-0.2.4.tar.gz
Algorithm Hash digest
SHA256 98829d98428fb02d7e04c6230e114c8e220ce9d34cd4c0501387a93ceae8d9a7
MD5 1386de7ec18013f2efaa049be33d4fc4
BLAKE2b-256 98be1e8c4bc8bf6dce2a23bcbdcea64606ffd441b1e0c8eeedd7d0eebe1a9811

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page