Skip to main content

Scripts and Python bindings for easy LDAP operations.

Project description

ezldap

Build Status Coverage Status PyPI version

An object-oriented Python LDAP API and set of bundled scripts to make common LDAP tasks easier.

Although several very comprehensive LDAP API's currently exist (notably python-ldap and ldap3), neither are particularly easy to use and generally focus more on the specifics of communicating via LDAP rather than exposing an easy to use high-level API. This package is designed to do that. The target audience of this package is system administrators and support staff who are on a timeline and just need to add a user or write a quick script in a portable manner.

So how is ezldap different? It is a wrapper around the ldap3 API that gives access to easily perform a number of high-level tasks like searching an LDAP directory, adding a user and sending them an email, or resetting someone's password securely. This process is streamlined by a configuration script that autodetects as many LDAP configuration values as possible and automates future connections to the directory server. Additionally, additions to an LDAP directory are performed using a set of configurable LDIF templates, making it very quick to customize the behavior of certain actions (like adding a group). Finally, for most tasks, a command-line interface is provided, for users who just want to get started doing stuff.

Python example:

import ezldap

with ezldap.auto_bind() as con:
    con.add_user('username', 'groupname', 'password')

Command-line example:

# a password will be automatically generated
ezldap add_user username groupname

Installation

You'll need a copy of Python 3.4+. No other dependencies are necessary, though pandas is useful for some use cases.

pip3 install --user git+https://github.com/jstaf/ezldap.git
ezldap config

Configure your LDAP connection details with ezldap config before using the package. You do not need to run this script as root. The connection details/LDIF templates/etc. for ezldap are stored in ~/.ezldap. Though you can store your bind password here for convenience, I do not recommend doing so, as it will be stored in cleartext. You may wish to configure the LDIF templates under ~/.ezldap as well if you intend to use this package's add object functionality.

Running tests

To run the tests, run the following after installation. You will need to have Docker installed - it is used to spawn a test LDAP server to run tests against.

pip3 install pytest pytest-cov pytest-docker docker-compose
pytest

Using this package

For command-line documentation and usage info, refer to the ezldap command's built-in documentation (ezldap -h and ezldap command -h). Keep in mind this package is under active development and may not be appropriate for all use cases. Functionality is constantly being added, and the API should not yet be considered stable.

For further information, check out the documentation!

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

ezldap-0.6.4.tar.gz (17.8 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