Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Temporary slapd launcher for testing purposes

Project Description

volatildap provides simple helpers for testing code against a LDAP database.

Its main features include:

  • Simple configuration: Don’t provide anything the LDAP server will start with sane defaults
  • Built-in cleanup: As soon as the test ends / the test process exits, the server is instantly removed
  • Cross-distribution setup: Automatically discover system paths for OpenLDAP binaries, schemas, etc.


import volatildap

class MyTests(unittest.TestCase):

    def setUpClass(cls):
        super(MyTests, cls).setUpClass()
        cls._slapd = volatildap.LdapServer(suffix='dc=example,dc=org')

    def setUp(self):
        # Will start the server, or reset/restart it if already started from a previous test.

    def test_something(self):
        conn = ldap.connection(self._slapd.uri)
        # Do some tests

    def test_with_data(self):
        # Load some data
        self._slapd.add({'ou=people': {'cn': [b'Users']}})
        # Run the tests

The volatildap.LdapServer provides a few useful methods:


Start or restart the server. This will:

  • Clear all data, if any
  • Start the server if it’s not yet running
  • Populate the initial data

Stop the server.

This will clean up all data and kill the proces.

Add some data, see the initial_data structure below.

Retrieve an object by its distinguished name;

Returns a dictionary mapping an attribute to the list of its values, as bytes.

Raises KeyError if the distinguished name is unknown to the underlying database.


The volatildap.LdapServer class accepts a few parameters:


The suffix to use for the LDAP tree

Default: dc=example,dc=org


The administrator account for the LDAP server

Default: cn=testadmin,dc=example,dc=org


The administrator password.

Default: A random value, available through LdapServer.rootpw


List of schemas to load; can be either a simple name (e.g cosine.schema; looked up in openldap installation); or a path to a custom one.

Default: ['core.schema']


Dict mapping a distinguished name to a dict of attribute/values:

    'ou=people': {
        'objectClass': ['organizationalUnit'],
        'cn': ['People'],

Note: When adding data, the suffix can be omitted on objects DNs.

Default: {}


When loading schemas, this flag instructs volatildap to continue if some schemas can’t be found.

Default: False


The port to use.

Default: An available TCP port on the system


The debug level for slapd; see slapd.conf

Default: 0


The maximum delay allowed for server startup, in seconds.

Default: 30

Per-distribution specificities

Under Ubuntu, the default AppArmor policy does not allow slapd (the LDAP daemon) to read temporary folders. Users should update the /etc/apparmor.d/usr.sbin.slapd file and add /tmp/** rw there.
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
volatildap-1.1.0-py2.py3-none-any.whl (10.8 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Jan 17, 2017
volatildap-1.1.0.tar.gz (15.1 kB) Copy SHA256 Checksum SHA256 Source Jan 17, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting