Repository navigation
Conversation
… claims Resolve every group through GetGroups, read its groupType in the existing base-scope lookup, and stop both the role claim and the traversal of its memberOf links when the group is not security-enabled. This matches how Active Directory computes the Windows token, where such groups are not part of the expansion graph. Behavior is unchanged when the groupType attribute is absent (non-AD servers) or when the AppContext switch Microsoft.AspNetCore.Authentication.Negotiate.AllowNonSecurityEnabledGroupClaims is set. Co-authored-by: Copilot <[email protected]>
Drive GetGroups through a LdapConnection subclass that overrides SendRequest, with SearchResponse objects built reflectively in one test helper, because the System.DirectoryServices.Protocols response types have no public constructors. Co-authored-by: Copilot <[email protected]>
rokonec
marked this pull request as ready for review
October 21, 2026 10:58
rokonec
requested review from
Youssef1313,
cincuranet,
davpetr and
halter73
as code owners
October 21, 2026 10:58
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
A non-AD compatibility regression remains unresolved, and independent validation of the changed default behavior is incomplete.
1 open issue
What changed in this PR
Updates Negotiate LDAP role resolution to omit distribution groups and stop traversing their parents.
Changes:
- Checks group type for direct and nested memberships.
- Adds a compatibility switch and debug logging.
- Adds LDAP traversal and group-type tests.
| File | Description |
|---|---|
| src/Security/Authentication/Negotiate/test/Negotiate.Test/Microsoft.AspNetCore.Authentication.Negotiate.Test.csproj | Adds the LDAP protocol test dependency. |
| src/Security/Authentication/Negotiate/test/Negotiate.Test/LdapAdapterTests.cs | Tests filtering, traversal, and compatibility behavior. |
| src/Security/Authentication/Negotiate/src/Internal/LdapAdapter.cs | Filters group claims and gates parent traversal. |
Review effort: Balanced
DeagleGross
self-requested a review
October 23, 2026 14:48
Member
Author
|
@copilot resolve the merge conflicts in this pull request |
Resolve overlapping LDAP adapter and test updates while preserving the group traversal change and current main behavior. Co-authored-by: Copilot <[email protected]>
4 tasks done
DeagleGross
approved these changes
Oct 26, 2026
Contributor
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
This branch has not been deployed
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.

Do not emit or traverse non-security-enabled groups in Negotiate LDAP claims
Description
When
EnableLdapis used, group memberships are resolved by followingmemberOflinks. Active Directory computes the Windows token over security-enabled groups only, so a group that is not security-enabled (a distribution group) is not part of the expansion and nothing is reachable through it. The LDAP path did not make that distinction.This change makes
LdapAdapterconsistent with that model:GetGroups(renamed fromGetNestedGroups), including whenIgnoreNestedGroupsistrue. In that mode only the recursion is skipped, not the group check.groupTypeis requested in the existing base-scope read, so there is no additional LDAP round trip.memberOflinks are not followed.groupType(non-Active Directory servers) fails open, so behavior there is unchanged. The bit test is done in C# rather than with the AD-specific bitwise matching rule.Microsoft.AspNetCore.Authentication.Negotiate.AllowNonSecurityEnabledGroupClaimsrestores the previous behavior (emit and traverse every group). It is read once into a static field.Debug.This is the same behavior that is already in
release/8.0andrelease/9.0, plus the traversal change on top, somainandrelease/10.0currently lack thegroupTypehandling this PR depends on. Because of that this PR contains the forward port and the traversal change together.One behavior to be aware of: a group whose entry no longer exists (stale
memberOfreference) no longer produces a role claim, because the claim is now added after the group is read. This matches the release branches.Tests
GetGroupsis exercised through aLdapConnectionsubclass that overridesSendRequest. TheSystem.DirectoryServices.Protocolsresponse types have no public constructors, so responses are built reflectively in one helper. The new tests cover:groupType: emitted and traversedIgnoreNestedGroupsboth valuesIsSecurityGroupandShouldEmitRoleClaimvalue matricesValidation on this branch:
dotnet test src\Security\Authentication\Negotiate\test\Negotiate.Test\Microsoft.AspNetCore.Authentication.Negotiate.Test.csproj: Passed 96, Failed 0.return;removed, exactly 2 tests fail (GetGroups_DistributionGroup_IsNotEmittedAndItsParentsAreNotTraversedandGetGroups_SecurityGroupBehindADistributionGroup_IsNotReached), with the extra role leaking, and the other tests still pass. The behavior was also checked end to end against a Samba AD domain controller.Fixes #69953