- Notifications
You must be signed in to change notification settings - Fork2
jstaf/ezldap
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An object-oriented Python LDAP API and set of bundled scripts to makecommon LDAP tasks easier.
Although several very comprehensive LDAP API's currently exist (notablypython-ldap
andldap3
), neither are particularly easy to use andgenerally focus more on the specifics of communicating via LDAP rather thanexposing an easy to use high-level API. This package is designed to do that.The target audience of this package is system administrators and supportstaff who are on a timeline and just need to add a user or write a quickscript in a portable manner.
So how isezldap
different? It is a wrapper around theldap3
API that gives access to easily perform a number of high-level taskslike searching an LDAP directory, adding a user and sending them anemail, or resetting someone's password securely. This process isstreamlined by a configuration script that autodetects as many LDAPconfiguration values as possible and automates future connections to thedirectory server. Additionally, additions to an LDAP directory are performedusing a set of configurable LDIF templates, making it very quick tocustomize the behavior of certain actions (like adding a group). Finally,for most tasks, a command-line interface is provided, for users who justwant to get started doing stuff.
Python example:
importezldapwithezldap.auto_bind()ascon:con.add_user('username','groupname','password')
Command-line example:
# a password will be automatically generatedezldap add_user username groupname
You'll need a copy of Python 3.4+.No other dependencies are necessary,thoughpandas
is useful for some use cases.
pip3 install --user git+https://github.com/jstaf/ezldap.gitezldap config
Configure your LDAP connection details withezldap config
before using the package.You do not need to run this script as root.The connection details/LDIF templates/etc. forezldap
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.
To run the tests, run the following after installation.You will need to haveDocker installed -it is used to spawn a test LDAP server to run tests against.
pip3 install pytest pytest-cov pytest-docker docker-composepytest
For command-line documentation and usage info,refer to theezldap
command's built-in documentation(ezldap -h
andezldap 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 thedocumentation!
About
Making LDAP suck less