Skip to content

Don't send the paged result control on Base scope searches - #104

Merged
jborean93 merged 1 commit into
jborean93:mainfrom
MacsInSpace:fix/rootdse-anonymous-paging
Aug 27, 2026
Merged

Don't send the paged result control on Base scope searches#104
jborean93 merged 1 commit into
jborean93:mainfrom
MacsInSpace:fix/rootdse-anonymous-paging

Conversation

@MacsInSpace

Copy link
Copy Markdown
Contributor

For #103

Get-OpenADRootDSE -AuthType Anonymous fails against a default Active Directory DC with "Cannot find AD RootDSE object", while the equivalent anonymous ldapsearch -x succeeds.

LdapSearchRequest adds PagedResultControl to every search. On a Base scope search the control can never do anything - the search returns at most one entry - and AD rejects it on an anonymous connection with:

000004DC: LdapErr: DSID-0C090C06, comment: In order to perform this
operation a successful bind must be completed on the connection.

The anonymous simple bind itself succeeds; it is only the control-bearing search that is refused. This can be reproduced without PSOpenAD, the only difference between these two being the control:

ldapsearch -x -H ldap://dc -s base -b "" defaultNamingContext
ldapsearch -x -H ldap://dc -s base -b "" -E pr=1000/noprompt defaultNamingContext

New-OpenADSession -AuthType Anonymous is affected the same way and ends up with an empty DefaultNamingContext, since session setup performs the same RootDSE lookup.

Skip pagination when the scope cannot produce more than one entry.

`Get-OpenADRootDSE -AuthType Anonymous` fails against a default Active
Directory DC with "Cannot find AD RootDSE object", while the equivalent
anonymous `ldapsearch -x` succeeds.

`LdapSearchRequest` adds `PagedResultControl` to every search. On a `Base`
scope search the control can never do anything - the search returns at most
one entry - and AD rejects it on an anonymous connection with:

    000004DC: LdapErr: DSID-0C090C06, comment: In order to perform this
    operation a successful bind must be completed on the connection.

The anonymous simple bind itself succeeds; it is only the control-bearing
search that is refused. This can be reproduced without PSOpenAD, the only
difference between these two being the control:

    ldapsearch -x -H ldap://dc -s base -b "" defaultNamingContext
    ldapsearch -x -H ldap://dc -s base -b "" -E pr=1000/noprompt defaultNamingContext

`New-OpenADSession -AuthType Anonymous` is affected the same way and ends up
with an empty DefaultNamingContext, since session setup performs the same
RootDSE lookup.

Skip pagination when the scope cannot produce more than one entry.
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.49%. Comparing base (0cadd7a) to head (500c501).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
+ Coverage   74.96%   80.49%   +5.53%     
==========================================
  Files          63       63              
  Lines        7073     7553     +480     
  Branches      901      902       +1     
==========================================
+ Hits         5302     6080     +778     
+ Misses       1587     1276     -311     
- Partials      184      197      +13     
Flag Coverage Δ
Linux_74_MIT 80.23% <100.00%> (+5.45%) ⬆️
Linux_75_MIT 80.23% <100.00%> (+5.45%) ⬆️
Linux_76_Heimdal 80.32% <100.00%> (+5.43%) ⬆️
Linux_76_MIT 80.23% <100.00%> (+5.45%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jborean93 jborean93 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for sending this through. Looks like I need to push a new release soon.

@jborean93
jborean93 merged commit 2b8f438 into jborean93:main Aug 27, 2026
8 checks passed
@MacsInSpace

Copy link
Copy Markdown
Contributor Author

No problems at all.
Also, I just noticed "Brisbane". I'm in Melbourne.
Do you mind if I shoot you a quick email? Not urgent.

@jborean93

Copy link
Copy Markdown
Owner

Sure thing

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