Repository navigation
Cherry-pick internal commits (release/9.0) - #67805
Merged
DeagleGross merged 2 commits intoJul 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks internal changes into release/9.0 to tighten LDAP-based role/claim resolution for Negotiate authentication by ensuring the authenticated principal’s realm matches the configured LDAP domain and by making nested-group traversal more deterministic.
Changes:
- Skip LDAP claim resolution when the user name has no realm (
@...) or when the realm doesn’t matchLdapSettings.Domain(case-insensitive). - Resolve nested groups by doing a base-scope lookup against each group’s distinguished name (DN), and handle stale
memberOfreferences. - Add/adjust tests to cover realm matching behavior and cache retrieval keyed by UPN-style names.
Show a summary per file
| File | Description |
|---|---|
| src/Security/Authentication/Negotiate/test/Negotiate.Test/NegotiateHandlerTests.cs | Updates test identities/cache keys to use [email protected] to align with new realm requirements. |
| src/Security/Authentication/Negotiate/test/Negotiate.Test/LdapAdapterTests.cs | Adds test coverage for realm mismatch/format skipping and cached-claim retrieval with realm casing variations. |
| src/Security/Authentication/Negotiate/src/Internal/LdapAdapter.cs | Enforces realm/domain match before LDAP lookup and switches nested-group resolution to DN base-scope queries with stale-reference handling. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Comment on lines
+126
to
+142
| private static void GetNestedGroups(LdapConnection connection, ClaimsIdentity principal, string distinguishedName, string groupDN, string groupCN, ILogger logger, IList<string> retrievedClaims, HashSet<string> processedGroups) | ||
| { | ||
| retrievedClaims.Add(groupCN); | ||
|
|
||
| var filter = $"(&(objectClass=group)(sAMAccountName={EscapeLdapFilterValue(groupCN)}))"; // This is using ldap search query language, it is looking on the server for someUser | ||
| var searchRequest = new SearchRequest(distinguishedName, filter, SearchScope.Subtree); | ||
| var searchResponse = (SearchResponse)connection.SendRequest(searchRequest); | ||
| // Look up the group entry by its distinguished name using base scope: | ||
| // a base-scope read against the DN is the only LDAP operation that | ||
| // returns exactly the intended group object. | ||
| var searchRequest = new SearchRequest(groupDN, "(objectClass=group)", SearchScope.Base); | ||
| SearchResponse searchResponse; | ||
| try | ||
| { | ||
| searchResponse = (SearchResponse)connection.SendRequest(searchRequest); | ||
| } | ||
| catch (DirectoryOperationException ex) when (ex.Response is SearchResponse r && r.ResultCode == ResultCode.NoSuchObject) | ||
| { | ||
| // Stale memberOf reference: group no longer exists. Stop traversal of this branch. | ||
| logger.LogDebug("Stale memberOf reference: group with distinguished name '{GroupDN}' no longer exists; stopping traversal.", groupDN);; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #67795