Skip to content

Add nested group resolution to LDAP group provider with optional AD matching-rule support#28492

Open
OmerRaifler wants to merge 2 commits intotrinodb:masterfrom
OmerRaifler:feature/add-nested-ldap-group-resolution
Open

Add nested group resolution to LDAP group provider with optional AD matching-rule support#28492
OmerRaifler wants to merge 2 commits intotrinodb:masterfrom
OmerRaifler:feature/add-nested-ldap-group-resolution

Conversation

@OmerRaifler
Copy link
Contributor

Motivation

  • Enable resolving nested LDAP group memberships (e.g., user → group A → group B) for the search-based LDAP group provider.
  • Provide an option to delegate nested membership resolution to Active Directory using the LDAP_MATCHING_RULE_IN_CHAIN matching rule to avoid recursive client-side lookups.
  • Document the new behavior and surface configuration knobs to control nested resolution and matching-rule usage.

Description

  • Added two new configuration properties: ldap.group-search-enable-nested-groups and ldap.group-search-use-matching-rule-in-chain and wired them into LdapFilteringGroupProviderConfig with getters, setters, and config annotations.
  • Implemented nested group resolution in LdapFilteringGroupProvider with three resolution modes: direct-only (resolveDirectGroups), recursive client-side resolution (resolveGroupsRecursively), and single-query AD matching-rule resolution (resolveGroupsInSingleQuery), which uses the matching rule OID 1.2.840.113556.1.4.1941 when enabled.
  • Consolidated group extraction into a new helper extractGroups and introduced a small LdapGroup record to carry both distinguished name and display name; updated search filter construction to support the matching-rule predicate.
  • Updated documentation group-mapping.md to describe the new properties and explain nested group behavior and the AD matching-rule option.
  • Updated tests and integration scenarios in TestLdapFilteringGroupProviderConfig and TestLdapGroupProviderIntegration to cover defaults, explicit mapping, and nested group behavior (added a nested engineering group and additional config builder for nested mode).

Testing

  • Ran the unit test TestLdapFilteringGroupProviderConfig to verify default values and property mapping, and it passed.
  • Ran the integration test TestLdapGroupProviderIntegration which exercises direct, recursive, and AD matching-rule flows via a test OpenLDAP server, and it passed.

@cla-bot cla-bot bot added the cla-signed label Mar 1, 2026
@github-actions github-actions bot added the docs label Mar 1, 2026
@OmerRaifler OmerRaifler force-pushed the feature/add-nested-ldap-group-resolution branch 3 times, most recently from 9c90ea8 to d0697cb Compare March 1, 2026 15:16
@OmerRaifler OmerRaifler marked this pull request as ready for review March 1, 2026 15:46
SearchResult groupResult = search.next();
Attribute groupName = groupResult.getAttributes().get(groupsNameAttribute);
if (groupName == null) {
log.warn("The group object [%s] does not have group name attribute [%s]. Falling back on object full name.", groupResult, groupsNameAttribute);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider debug log level to avoid this warning being thrown for every user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that warning on every malformed group entry can become noisy.
I changed the implementation to log the per-entry details at debug, and emit a single warn if any group is missing the configured ldap.group-name-attribute. That preserves operator visibility for misconfiguration or unexpected LDAP schema while avoiding repeated warnings for every user lookup.

* - `ldap.group-search-member-attribute`
- Attribute from group documents used for filtering by member. For example,
`cn`.
* - `ldap.group-search-enable-nested-groups`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sort the configuration keys alphabetically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or consider renaming them so all nested properties stay grouped (😉), so 'ldap.group-search-nested-enable' and 'ldap.group-search-nested-use-matching-rule-in-chain'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the properties 🙌

@gertjanal
Copy link
Contributor

gertjanal commented Mar 2, 2026

I'm not able to test it IRL, but the code looks good.
I don't have the permission to approve it though

@OmerRaifler OmerRaifler force-pushed the feature/add-nested-ldap-group-resolution branch from d0697cb to 32b3342 Compare March 14, 2026 16:29
@OmerRaifler
Copy link
Contributor Author

I'm not able to test it IRL, but the code looks good. I don't have the permission to approve it though

Thanks for the review and positive feedback! I will bump this on Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants