1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-28 04:04:30 +01:00
ldapcherry/docs/backend_api.rst
kakwa aa7db36efc using demo backend as an example
the demo backend is far simplier than the ldap backend,
so it's more logic to use it as an implementation example
2015-08-09 19:38:23 +02:00

1.7 KiB

Implementing cutom backends

API

The backend modules must respect the following API:

ldapcherry.backend.Backend

Configuration

Configuration for your backend is declared in the main ini file, inside [backends] section:

For example with the configuration:

[backends]

# class path to module
b_id.module = "my.backend.module"

b_id.param1 = "my value 1"
b_id.param2 = "my value 2"

Note

One module can be instanciated several times, the prefix b_id permits to differenciate instances and their specific configuration.

The following hash will be passed as configuration to the module constructor as parameter config:

{
    'param1': "my value 1",
    'param2': "my value 2",
}

After having set self.config to config in the constructor, parameters can be recovered by self.get_param:

ldapcherry.backend.Backend

Exceptions

The following exception can be used in your module

ldapcherry.exceptions

These exceptions permit a nicer error handling and avoid a generic message to be thrown at the user.

Example

Here is the ldap backend module that comes with LdapCherry:

../ldapcherry/backend/backendDemo.py