Skip to content

Knox 3533: Skip group membership resolution in LdapProxyBackend when memberOf is not requested - #1475

Merged
smolnar82 merged 3 commits into
apache:masterfrom
handavid:KNOX-3533-skip-group-membership
Nov 6, 2026
Merged

smolnar82 merged 3 commits into
apache:masterfrom
handavid:KNOX-3533-skip-group-membership

Conversation

@handavid

Copy link
Copy Markdown
Contributor

KNOX-3533 - Skip group membership resolution in LdapProxyBackend when memberOf is not requested

What changes were proposed in this pull request?

Pass the client's requested attributes from UserSearchInterceptor to LdapBackend.search() so LdapProxyBackend only resolves group memberships when memberOf (or *) is requested.

How was this patch tested?

Unit tests were updated for the new functionality.

Manual search queries were run against the LDAP proxy to compare the results and time. Proxy was configured with recursive member resolution and the default depth of 3

    <property>
        <name>gateway.ldap.recursive.group.resolution</name>
        <value>true</value>
    </property>

The LdapProxyBackend was exercised with with useMemberOf configured both on and off

results with useMemberOf on:

# query w/ memberOf attribute
time ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=BIND2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -b 'ou=people,DC=proxy,DC=com' -s sub '(uid=*)' uid objectclass memberof
...
# numResponses: 494
# numEntries: 492
ldapsearch -v -x -H ldap://localhost:3890 -D  -w bind-password -E  -b  -s sub  0.01s user 0.02s system 0% cpu 7.007 total

# query w/o memberOf attribute
time ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=BIND2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -b 'ou=people,DC=proxy,DC=com' -s sub '(uid=*)' uid objectclass
...
# numResponses: 494
# numEntries: 492
ldapsearch -v -x -H ldap://localhost:3890 -D  -w bind-password -E  -b  -s sub  0.01s user 0.01s system 1% cpu 1.718 total

Since memberOf is enabled, this optimization saves time by skipping the recursive member resolution

results with useMemberOf off:

# query w/ memberOf attribute
time ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=BIND2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -b 'ou=people,DC=proxy,DC=com' -s sub '(uid=*)' uid objectclass memberof
...
# numResponses: 494
# numEntries: 492
ldapsearch -v -x -H ldap://localhost:3890 -D  -w bind-password -E  -b  -s sub  0.01s user 0.02s system 0% cpu 1:05.76 total

# query w/o memberOf attribute
time ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=BIND2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -b 'ou=people,DC=proxy,DC=com' -s sub '(uid=*)' uid objectclass
...
# numResponses: 494
# numEntries: 492
ldapsearch -v -x -H ldap://localhost:3890 -D  -w bind-password -E  -b  -s sub  0.01s user 0.02s system 1% cpu 2.324 total

When useMemberOf is not enabled, group membership is found using searches per user. This leads to a large fan-out of searches if the number of users is large.

Integration Tests

Integration tests were run, but no new integration tests were added because there should be no change in the results retrieved through the LDAP Proxy.

UI changes

No UI changes

@handavid

Copy link
Copy Markdown
Contributor Author

@hanicz @pzampino

@smolnar82
smolnar82 requested review from hanicz, moresandeep and smolnar82 and removed request for smolnar82 November 2, 2026 16:15
@smolnar82 smolnar82 added the ldap label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Test Results

  5 files    5 suites   1m 30s ⏱️
198 tests 196 ✅ 2 💤 0 ❌
239 runs  237 ✅ 2 💤 0 ❌

Results for commit ba3431b.

♻️ This comment has been updated with latest results.

@smolnar82 smolnar82 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only a nitpick comment that should be fixed in the JavaDoc IMO.

handavid and others added 2 commits November 4, 2026 21:33
…memberOf is not requested

Pass the client's requested attributes from UserSearchInterceptor to LdapBackend.search()
so LdapProxyBackend only resolves group memberships when memberOf (or *) is requested.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@handavid
handavid force-pushed the KNOX-3533-skip-group-membership branch from 6ea5544 to 2d0a183 Compare November 5, 2026 04:22
@smolnar82
smolnar82 merged commit 84522e8 into apache:master Nov 6, 2026
3 checks passed
@handavid
handavid deleted the KNOX-3533-skip-group-membership branch November 6, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants