Skip to content

KNOX-3575: Add sizeLimit and timeLimit parameters to LdapBackend.search - #1514

Merged
lmccay merged 1 commit into
apache:masterfrom
handavid:KNOX-3575-sizelimit
Nov 14, 2026
Merged

lmccay merged 1 commit into
apache:masterfrom
handavid:KNOX-3575-sizelimit

Conversation

@handavid

Copy link
Copy Markdown
Contributor

KNOX-3757 - LDAP Proxy passes sizelimit to backend

What changes were proposed in this pull request?

Thread the per-request size and time limits from the SearchOperationContext through UserSearchInterceptor into the backends.

FileBackend respects sizeLimit by truncating results (timeLimit is not applicable to its in-memory lookups). LdapProxyBackend forwards timeLimit to the remote server on each page and enforces sizeLimit client-side, combined with the configured maxResultSetSize (smaller positive bound wins).

A backward-compatible default search() overload delegates with no limits.

How was this patch tested?

Ran updated unit tests.

Manually tested through ldapsearch with sizelimit against an Active Directory backend with ~500 users

search w/o sizelimit for comparison

time ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=bind2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -e "1.3.6.1.4.1.18060.18.0.1=AQH/" -b 'ou=people,DC=proxy,DC=com' -s sub '(objectClass=inetOrgPerson)' '*'
...
# numResponses: 472
# numEntries: 470
ldapsearch -v -x -H ldap://localhost:3890 -D  -w bind-password -E  -e  -b  -s  0.01s user 0.02s system 0% cpu 6.726 total

search w/ sizelimit 10 prior to this change

time ldapsearch -v -x -H ldap://localhost:3890 -z 10 -D 'uid=bind2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -e "1.3.6.1.4.1.18060.18.0.1=AQH/" -b 'ou=people,DC=proxy,DC=com' -s sub '(objectClass=inetOrgPerson)' '*' 
...
# numEntries: 10
ldapsearch -v -x -H ldap://localhost:3890 -z 10 -D  -w bind-password -E  -e    0.01s user 0.01s system 0% cpu 6.075 total

search w/ sizelimit 10 after this change

time ldapsearch -v -x -H ldap://localhost:3890 -z 10 -D 'uid=bind2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt  -e "1.3.6.1.4.1.18060.18.0.1=AQH/" -b 'ou=people,DC=proxy,DC=com' -s sub '(objectClass=inetOrgPerson)' '*' 
...
# numEntries: 10
ldapsearch -v -x -H ldap://localhost:3890 -z 10 -D  -w bind-password -E  -e    0.01s user 0.01s system 1% cpu 1.078 total

Integration Tests

No integration tests were updated because this feature is not visible through the integration tests (other than potentially execution time)

UI changes

No UI changes

@handavid
handavid force-pushed the KNOX-3575-sizelimit branch from 1877403 to 038e7d3 Compare November 14, 2026 18:48
…ch()

Thread the per-request size and time limits from the SearchOperationContext
through UserSearchInterceptor into the backends.

FileBackend respects sizeLimit by truncating results (timeLimit is not
applicable to its in-memory lookups). LdapProxyBackend forwards timeLimit to
the remote server on each page and enforces sizeLimit client-side, combined
with the configured maxResultSetSize (smaller positive bound wins). A
backward-compatible default search() overload delegates with no limits.

While here, fix FileBackend user matching to use standard LDAP filter
semantics: searchUsers now evaluates the parsed filter against each user
entry via LdapUtils.matchesFilter instead of an ad-hoc substring check, so
wildcard, presence, substring and boolean assertions behave correctly. The
backend also exposes the username under sAMAccountName (in addition to uid)
so AD-style user searches continue to resolve the same user.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@handavid
handavid force-pushed the KNOX-3575-sizelimit branch from 038e7d3 to 3f85a84 Compare November 14, 2026 19:05
@handavid

Copy link
Copy Markdown
Contributor Author

@smolnar82

@lmccay lmccay 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.

Changes look good to me.
I'll merge once the checks pass.

@github-actions

Copy link
Copy Markdown

Test Results

  5 files    5 suites   1m 45s ⏱️
222 tests 220 ✅ 2 💤 0 ❌
263 runs  261 ✅ 2 💤 0 ❌

Results for commit 3f85a84.

@lmccay
lmccay merged commit 1976c95 into apache:master Nov 14, 2026
3 checks passed
@lmccay

lmccay commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

@handavid - I have merged this and it will be available in the next release.
Thanks for your contribution!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants