This module allows Anjana to synchronize users from an LDAP or Active Directory directory using the LDAPv3 protocol.
Unlike the other providers, LDAP has no section of its own under security.provisioning: the connection is configured once in security.authentication.ldap and is the same one used by login.
Important: synchronization is enabled simply by the presence of the security.authentication.ldap.url property. There is no independent switch for synchronization: if LDAP is configured for login, its users are also synchronized.
Part 1: Configuration in the directory
Anjana needs a service user with read-only permissions: it must be able to search for users under the configured base-dn and read the attributes that are synchronized (see the Synchronized attributes section).
Configuring the service user (connection-user-dn and connection-user-password) is always recommended. If they are not set, Anjana sends no connection credentials to the directory.
Part 2: Configuration in application.yml
Edit the Zeus microservice configuration file and include the data in the security.authentication.ldap section.
OpenLDAP example
security:
authentication:
ldap:
# LDAP server URL and port
url: ldap://ldapservice:10389
# Base DN from which users are searched
base-dn: dc=anjanadata,dc=org
# Structural class that identifies users
user-structural-class: person
# Attribute holding the username (it becomes the userName in Anjana)
user-search-attribute: cn
# Service user with read permissions
connection-user-dn: uid=admin,ou=system
connection-user-password: "${LDAP_PROVISIONING_PASSWORD}"
# Mandatory because it is shared with login; it plays no part in synchronization
user-authentication: USER_PASSWORD_ENC
user-search-filter: (cn={0})
Active Directory example
security:
authentication:
ldap:
url: ldap://ad.my-domain.com:389
base-dn: dc=my-domain,dc=com
user-structural-class: user
user-search-attribute: sAMAccountName
connection-user-dn: cn=svc-anjana,ou=Services,dc=my-domain,dc=com
connection-user-password: "${LDAP_PROVISIONING_PASSWORD}"
user-authentication: USER_PASSWORD_ENC
user-search-filter: (sAMAccountName={0})
TLS management (ldaps:// and certificates) is the general Anjana one. See the installation manuals.
Part 3: Scheduling the synchronization
Synchronization is a background process that goes through all configured providers (LDAP included) and creates or updates the users in Anjana's database. It can be launched in two ways:
-
Scheduled: according to the cron expression of the
anjana.scheduling.synchronizeUserssetting. It is edited in the Administration module, under Settings, with the label Synchronize users cron. In environments with several Zeus instances, only one runs each launch (distributed lock). -
Manual: with the call
GET /api/admin/zeus/users/synchronization, which requires a user with the API administration role. It returns 200 immediately and the synchronization continues in the background.
This setting has no default value: it must be configured for the scheduled synchronization to run. Example (not a default value), to run it every day at 03:00:
anjana:
scheduling:
synchronizeUsers: "0 0 3 * * *"
The value - disables the scheduled execution.
Synchronized attributes
Anjana searches for entries matching (&(objectClass=<user-structural-class>)(<user-search-attribute>=*)) across the whole tree under base-dn.
|
Anjana field |
LDAP attribute (default) |
Notes |
|---|---|---|
|
|
the one set in |
No default value, mandatory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Employee number: the employee-search-attribute property (default employeeNumber) is read from the directory, but the synchronization does not store it in Anjana.
Custom attribute mapping
Unlike other providers, LDAP does not use field-mapping. The mapping is changed with the properties in the table above. For the email, a list in priority order can be set:
security:
authentication:
ldap:
name-search-attribute: givenName
surname-search-attribute: sn
phone-search-attribute: mobile
title-search-attribute: title
anjana:
mail:
ldap: ["mail", "userPrincipalName"]
Synchronization behavior
-
Paging: the search runs in pages of 500 entries over a single connection, compatible with Active Directory's 1000-result limit.
-
Timeouts:
connect-timeout-ms(5000 by default) andread-timeout-ms(60000 by default). The read timeout applies per page, not to the total. -
Creations and updates: new users are created and existing ones are updated. Users that disappear from the directory are not deleted or deactivated.
-
Errors: if LDAP fails, the error is logged and the synchronization continues with the remaining providers. LDAP users are simply not updated in that run.
-
Referrals: they are followed automatically, for example in Active Directory subdomains.
Summary of required data
|
YAML property |
Description |
Required |
|---|---|---|
|
|
LDAP server URL and port. Its presence enables the module. |
YES |
|
|
Base DN of the searches. |
YES |
|
|
Class that identifies users ( |
YES |
|
|
Attribute holding the username ( |
YES |
|
|
Login authentication mode. It plays no part in synchronization. |
YES |
|
|
Read-only service user. |
Recommended |
|
|
Cron expression of the scheduled synchronization. No default value. |
For scheduled execution |