Ldappr
Ldappr is a wrapper around python-ldap, meant for quick and easy handling of common administrative tasks concerning your LDAP compliant repository. It is particularly useful in small, one-time scripts to get things done, or interactively within an iPython shell.
Installation
Of course, python-ldap is supposed to be already installed.
pip install ldappr
Connect
import ldappr
# authenticated bind
ldap = ldappr.connect_to('127.0.0.1', 'uid=admin,ou=system', 'secret')
Retrieve objects
When you have a connection, you can search on it. First, specify the seach base.
ldap.search_base = 'ou=users,ou=system'
Then, get one or more objects to manipulate.
# retrieve a single object
user = ldap.get('cn=jdoe')
# retrieve a list of objects
users = ldap.search('objectClass=inetOrgPerson')
Do stuff
Once you got an object, you can easily manipulate it. All changes will immediately reflect in your LDAP repository.
# pretty print the retrieved user
print(user)
# get an attribute value
sn = user.attrs['sn']
# set an attribute value (existing value will be removed)
user.set_value('givenName', 'Jack')
# add a value to a multi-valued attribute
user.add_value('mobile', '0123456789')
user.add_value('mobile', '9876543210')
# remove a value from a multi-valued attribute
user.remove_value('mobile', '9876543210')
Other examples
# anonymous bind
ldap = ldappr.connect_to('127.0.0.1')
# authenticated bind with more options
ldap = ldappr.connect_to('127.0.0.1', 'uid=admin,ou=system', 'secret',
protocol='ldaps', port='10636', verify=False,
search_base='ou=users,ou=system')
# delete all objects with employeeType manager
for dn in ldap.get_dn('employeeType=manager'):
ldap.delete(dn)
# set an attribute value for a known dn
ldap.set_value('cn=jdoe,ou=users,ou=system', 'givenName', 'Jack')
# make an LDIF export for all users
with open('export.ldif', 'a') as file:
for user in ldap.search('objectClass=inetOrgPerson'):
file.write(user.to_ldif())
Metadata
Release files for ldappr 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ldappr-0.1.5.tar.gz | 6.4 kB | Without provenance | Details for ldappr-0.1.5.tar.gz |
Release files / ldappr-0.1.5.tar.gz
| Download URL | ldappr-0.1.5.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
935d0c9158ebb7bce8ae31081cd387e389756d5cd160245d7bf7ca0edc7a2e63
|
|
BLAKE2b-256 checksum How to use checksums |
957d4be0932ca8d83c8806afe03af9a69fae738b480201bd106dd0e5f9ae7b4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ldappr 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.