Sync OpenDJ Nested Groups to Keycloak

When integrating OpenDJ with Keycloak, syncing LDAP groups, especially nested groups, as Keycloak groups is essential for centralized, scalable access control across applications.

Unlike OpenLDAP, OpenDJ supports nested groups natively and exposes them through the isMemberOf virtual attribute. This allows Keycloak to assign roles based on both direct and indirect group membership, without custom scripts or overlays.


Prerequisites

Before proceeding, make sure you have completed the following:


  1. Connect OpenDJ to Keycloak
  • Navigate to User Federation
  • Click Add LDAP provider
  • Fill in the configuration using the table below
SectionSettingValue
General OptionsDisplay NameOpenDJ
VendorOther
Connection and AuthenticationConnection URLldaps://ldap.maksonlee.com:636
Enable StartTLS❌ Off
Use Truststore SPI✅ Always
Connection Pooling✅ On
Bind Typesimple
Bind DNcn=Directory Manager
Bind Credentials(LDAP admin password)
LDAP Searching and UpdatingEdit Mode✅ WRITABLE
Users DNou=people,dc=maksonlee,dc=com
User LDAP Filter(employeeType=active)
Username LDAP Attributeuid
RDN LDAP Attributeuid
UUID LDAP AttributeentryUUID
User Object ClassesinetOrgPerson
Search ScopeSubtree
Pagination✅ On
Referralignore
SynchronizationImport Users✅ On
Sync Registrations❌ Off
Remove Invalid Users During Searches✅ On
Periodic Full Sync❌ Off
Periodic Changed Users Sync❌ Off
Advanced SettingsLDAPv3 Password Modify Extension✅ On
Validate Password Policy❌ Off
Trust Email✅ On

  1. Create Group Mapper

After saving the LDAP provider:

  • Go to User Federation > [your OpenDJ provider] > Mappers > Add mapper

Fill in the mapper settings:

FieldValue
Nameldap-groups
Mapper Typegroup-ldap-mapper
LDAP Groups DNou=groups,dc=maksonlee,dc=com
Relative Creation DN(leave empty)
Group Name LDAP Attributecn
Group Object ClassesgroupOfNames
Preserve Group InheritanceOn
Membership LDAP Attributemember
Membership Attribute TypeDN
Membership User LDAP Attributeuid
LDAP Filter(objectClass=groupOfNames)
ModeREAD_ONLY
User Groups Retrieve StrategyGET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE
Member-Of LDAP AttributeisMemberOf

  1. Sync Users from OpenDJ

After saving the mapper, click the Action button on the right, then select Sync LDAP groups to Keycloak.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top