Configuring LDAP with AEM 6

Last update: 2023-05-03
  • Created for:
  • Admin

AEM 6.4 has reached the end of extended support and this documentation is no longer updated. For further details, see our technical support periods. Find the supported versions here.

LDAP (the Lightweight Directory Access Protocol) is used for accessing centralized directory services. This helps reduce the effort required to manage user accounts as they can be accessed by multiple applications. One such LDAP server is Active Directory. LDAP is often used to achieve Single Sign On which allows a user to access multiple applications after logging in once.

User accounts can be synchronized between the LDAP server and the repository, with LDAP account details being saved in the repository. This allows the accounts to be assigned to repository groups for allocating the required permissions and privileges.

The repository uses LDAP authentication to authenticate such users, with credentials being passed to the LDAP server for validation, which is required before allowing access to the repository. To improve performance, successfully validated credentials can be cached by the repository, with an expiry timeout to ensure that revalidation does occur after an appropriate period.

When an account is removed from the LDAP server validation is no longer granted and so access to the repository is denied. Details of LDAP accounts that are saved in the repository can also be purged.

Use of such accounts is transparent to your users, they see no difference between user and group accounts created from LDAP and those created solely in the repository.

In AEM 6, LDAP support comes with a new implementation that requires a different type of configuration than with previous versions.

All LDAP configurations are now available as OSGi configurations. They can be configured via the Web Management console at:

In order to have LDAP working with AEM, you need to create three OSGi configurations:

  1. An LDAP Identity Provider (IDP).
  2. A Sync Handler.
  3. An External Login Module.

Watch [Oak’s External Login Module - Authenticating with LDAP and Beyond] to deep dive External Login Modules.

To read an example of configuring Experience Manager with Apache DS, see Configuring Adobe Experience Manager 6.4 to use Apache Directory Service.

Configuring The LDAP Identity Provider

The LDAP Identity Provider is used to define how users are retrieved from the LDAP server.

It can be found in the management console under the Apache Jackrabbit Oak LDAP Identity Provider name.

The following configuration options are available for the LDAP Identity Provider:

LDAP Provider Name Name of this LDAP provider configuration.
LDAP Server Hostname
Hostname of the LDAP server
LDAP Server Port Port of the LDAP server
Use SSL Indicates if an SSL (LDAPs) connection should be used.
Use TLS Indicates if TLS should be started on connections.
Disable certificate checking Indicates if server certificate validation should be disabled.
Bind DN DN of the user for authentication. If this is left empty, an anonymous bind will be performed.
Bind Password Password of the user for authentication
Search timeout Time until a search times out
Admin pool max active The maximum active size of the admin connection pool.
User pool max active The maximum active size of the user connection pool.
User base DN The DN for user searches
User object classes The list of object classes an user entry must contain.
User id attribute Name of the attribute that contains the user id.
User extra filter Extra LDAP filter to use when searching for users. The final filter is formatted like: '(&(<idAttr>=<userId>)(objectclass=<objectclass>)<extraFilter>)' (user.extraFilter)
User DN paths Controls if the DN should be used for calculating a portion of the intermediate path.
Group base DN The base DN for group searches.
Group object classes The list of object classes a group entry must contain.
Group name attribute Name of the attribute that contains the group name.
Group extra filter Extra LDAP filter to use when searching for groups. The final filter isformatted like: '(&(<nameAttr>=<groupName>)(objectclass=<objectclass>)<extraFilter>)'
Group DN paths Controls if the DN should be used for calculating a portion of the intermediate path.
Group member attribute Group attribute that contains the member(s) of a group.

Configuring The Synchronization Handler

The synchronization handler will define how the Indentity Provider users and groups will be synchronized with the repository.

It is located under the Apache Jackrabbit Oak Default Sync Handler name in the management console.

The following configurations options are available for the Synchronization Handler:

Sync Handler Name Name of the sync configuration.
User Expiration Time Duration until a synced user gets expired.
User auto membership List of groups that a synced user is added to automatically.
User property mapping List mapping definition of local properties from external ones.
User Path Prefix The path prefix used when creating new users.
User Membership Expiration Time after which membership expires.
User membership nesting depth Returns the maximum depth of group nesting when membership relations are synced. A value of 0 effectively disables group membership lookup. A value of 1 only adds the direct groups of a user. This value has no effect when syncing individual groups only when syncing a users membership ancestry.
Group Expiration Time Duration until a synced group expires.
Group auto membership List of groups that a synced group is added to automatically.
Group property mapping List mapping definition of local properties from external ones.
Group path prefix The path prefix used when creating new groups.

The external login module

The external login module is located under the Apache Jackrabbit Oak External Login Module under the management console.


The Apache Jackrabbit Oak External Login Module implements the Java Authentication and Authorization Servi (JAAS) specifications. See the official Oracle Java Security Reference Guide for more information.

Its job is to define which Identity Provider and Sync Handler to use, effectively binding the two modules.

The following configuration options are available:

JAAS Ranking Specifying the ranking (i.e. sort order) of this login module entry. The entries are sorted in a descending order (i.e. higher value ranked configurations come first).
JAAS Control Flag Property specifying whether or not a LoginModule is REQUIRED, REQUISITE, SUFFICIENT or OPTIONAL.Refer to the JAAS configuration documentation for more details around the meaning of these flags.
JAAS Realm The realm name (or application name) against which the LoginModule is be registered. If no realm name is provided then LoginModule is registered with a default realm as configured in the Felix JAAS configuration.
Identity Provider Name Name of the identity provider.
Sync Handler Name Name of the sync handler.

If you plan on having more than one LDAP configuration with your AEM instance, separate Identity Providers and Synchronization Handlers need to be created for each configuration.

Configure LDAP over SSL

AEM 6 can be configured to authenticate with LDAP over SSL by following the below procedure:

  1. Check the Use SSL or Use TLS checkboxes when configuring the LDAP Identity Provider.

  2. Configure the Sync Handler and the External Login module according to your setup.

  3. Install the SSL certificates in your Java VM if needed. This can be done by using keytool:

    keytool -import -alias localCA -file <certificate location> -keystore <keystore location>

  4. Test the connection to the LDAP server.

Creating SSL certificates

Self signed certificates can be used when configuring AEM to authenticate with LDAP via SSL. Below is an example of a working procedure for generating certificates for use with AEM.

  1. Make sure you have a SSL library installed and working. This procedure will use OpenSSL as an example.

  2. Create a customized OpenSSL configuration (cnf) file. This can be done by copying the default **openssl.cnf **configuration file and customizing it. On UNIX systems, it is usually located at /usr/lib/ssl/openssl.cnf

  3. Proceed to creating the CA root key by running the below command in a terminal:

    openssl genpkey -algorithm [public key algorithm] -out certificatefile.key -pkeyopt [public key algorithm option]
  4. Next, create a new self signed certificate:

    openssl req -new -x509 -days [number of days for certification] -key certificatefile.key -out root-ca.crt -config CA/openssl.cnf

  5. Inspect the newly generated certificate to make sure everything is in order:

    openssl x509 -noout -text -in root-ca.crt

  6. Make sure that all folders specified in the certificate configuration (.cnf) file exist. If not, create them.

  7. Create a random seed, by running, for example:

    openssl rand -out private/.rand 8192

  8. Move the created .pem files to the locations configured in the .cnf file.

  9. Finally, add the certificate to the Java keystore.

Enabling debug logging

Debug logging can be enabled for both the LDAP Identity Provider and the External Login Module in order to troubleshoot connection issues.

In order to enable debug logging, you need to:

  1. Go to the Web Management Console.
  2. Find “Apache Sling Logging Logger Configuration” and create two loggers with the follwoing options:
  • Log level: Debug

  • Log File logs/ldap.log

  • Message Pattern: {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* {2}

  • Logger:

  • Log level: Debug

  • Log File: logs/external.log

  • Message Pattern: {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* {2}

  • Logger:

A Word on Group Affiliation

Users synchronized through LDAP can be part of different groups in AEM. These groups can be external LDAP groups that will be added to AEM as part of the synchronization process, but they can also be groups that are added separately and are not part of the original LDAP group affiliation scheme.

In most cases, these can be groups that are added by a local AEM administrator or by any other identity provider.

If a user is removed from a group on the LDAP server, the change will also be reflected on the AEM side upon synchronization. However, all the other group affiliations of the user that were not added by LDAP will remain in place.

AEM detects and handles the purging of users from external groups by making use of the rep:externalId property. This property is added automatically to any user or group that is synchronized by the Synchronization Handler and it contains information on the originating identity provider.

For more information, see Apache Oak documentation on User and Group Synchronization.

Known issues

If you plan on using LDAP over SSL, make sure the certificates you are using are created without the Netscape comment option. If this option is enabled, authentication will fail with a SSL Handshake error.

On this page