Skip to main content

Python lib for common OpenLDAP queries @ Mozilla. This only works with LDAP databases using a schema similar to Mozilla's.

Project description

Python lib for common OpenLDAP queries @ Mozilla. This only works with LDAP databases using a schema similar to Mozilla’s.

Install

Using pip

sudo apt-get install libldap2-dev libsasl2-dev
pip install mozlibldap

As a python module

Manually: .. code:

make install

As a rpm/deb package .. code:

make rpm
make deb
rpm -i <package.rpm>
dpkg -i <package.deb>

Testing

Fill in the LDAP URL, login, password in tests.py and run it :)

From the code/integrate in my code

Add to your project with:

git submodule add https://github.com/mozilla-it/mozlibldap
git commit -a

Python dependencies

  • python-ldap

Usage

Login/pass:

import mozlibldap

l = mozlibldap.MozLDAP(LDAP_URL, LDAP_BIND_DN, LDAP_BIND_PASSWD)
print(l.get_user_posix_uid("gdestuynder@mozilla.com"))

With client certificate (the certificate DN needs to match your LDAP DN). The client cert, key file and optional ca cert (last argument) are all PEM files.

import mozlibldap

l = mozlibldap.MozLDAP(LDAP_URL, LDAP_BIND_DN, None, LDAP_BIND_CLIENTCERT, LDAP_BIND_KEYFILE)
# If using a self-signed CA in a specific location, like Mozilla CA
#l = mozlibldap.MozLDAP(LDAP_URL, LDAP_BIND_DN, None, LDAP_BIND_CLIENTCERT, LDAP_BIND_KEYFILE,
#                       "/etc/ssl/mozca.pem")
print(l.get_user_posix_uid("gdestuynder@mozilla.com"))

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

mozlibldap-1.1.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file mozlibldap-1.1.0.tar.gz.

File metadata

  • Download URL: mozlibldap-1.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mozlibldap-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6298e4f46a2677845734ed3a7164f50a49a0b6f74b0880db69d95131cd94b292
MD5 459ef2496eceac544dfc4fc6961ec507
BLAKE2b-256 fc4844fe608f55790a2d2862e097433b68ac1db1a28d625d120183af6bfaabe6

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