Configuring LDAP with AEM 6

LDAP (the Lightweight Directory Access Protocol) is used for accessing centralized directory services. It 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 functionality 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 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. That is, they see no difference between user and group accounts created from LDAP, and accounts 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:
https://serveraddress:4502/system/console/configMgr

To have LDAP working with AEM, you must create three OSGi configurations:

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

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.5 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 field is left empty, an anonymous bind is 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 that a 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 one or more members of a group.

Configuring The Synchronization Handler

The synchronization handler defines how the Identity Provider users and groups are 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 automatically added to.
User property mapping List-mapping definition of local properties from external ones.
User Path Prefix The path prefix used when creating 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 automatically added to.
Group property mapping List-mapping definition of local properties from external ones.
Group path prefix The path prefix used when creating groups.

The external login module

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

NOTE

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 (that is, sort order) of this login module entry. The entries are sorted in a descending order (that is, higher value ranked configurations come first).
JAAS Control Flag Property specifying whether a LoginModule is REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL. See 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 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.
NOTE

If you plan on having more than one LDAP configuration with your AEM instance, separate Identity Providers and Synchronization Handlers must 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 installation 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 an SSL library installed and working. This procedure uses OpenSSL as an example.

  2. Create a customized OpenSSL configuration (cnf) file. This configuration can be done by copying the default **openssl.cnf **configuration file and customizing it. On UNIX® systems, it is 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 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. To make sure that everything is in order, inspect the newly generated certificate:

    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 to troubleshoot connection issues.

To enable debug logging, you must do the following:

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

  • Log File logs/ldap.log

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

  • Logger: org.apache.jackrabbit.oak.security.authentication.ldap

  • Log level: Debug

  • Log File: logs/external.log

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

  • Logger: org.apache.jackrabbit.oak.spi.security.authentication.external

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 are added to AEM as part of the synchronization process. However, they can also be groups that are added separately and are not part of the original LDAP group affiliation scheme.

Usually, these groups 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 is reflected on the AEM side on synchronization. However, all the other group affiliations of the user that were not added by LDAP remain in place.

AEM detects and handles the purging of users from external groups by using 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.

See Apache Oak documentation on User and Group Synchronization.

Known issues

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

On this page