Skip to content

Commit c6c4516

Browse files
committed
LdapAdapter: Fix nested claims retrieval -- use CN instead of DN
1 parent 9b6afb4 commit c6c4516

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Security/Authentication/Negotiate/src/Internal/LdapAdapter.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,15 @@ private static void GetNestedGroups(LdapConnection connection, ClaimsIdentity pr
110110
}
111111

112112
var group = searchResponse.Entries[0]; //Get the object that was found on ldap
113-
string name = group.DistinguishedName;
114-
retrievedClaims.Add(name);
113+
retrievedClaims.Add(groupCN);
115114

116115
var memberof = group.Attributes["memberof"]; // You can access ldap Attributes with Attributes property
117116
if (memberof != null)
118117
{
119118
foreach (var member in memberof)
120119
{
121-
var groupDN = $"{Encoding.UTF8.GetString((byte[])member)}";
122-
var nestedGroupCN = groupDN.Split(',')[0].Substring("CN=".Length);
120+
var nestedGroupDN = $"{Encoding.UTF8.GetString((byte[])member)}";
121+
var nestedGroupCN = nestedGroupDN.Split(',')[0].Substring("CN=".Length);
123122
GetNestedGroups(connection, principal, distinguishedName, nestedGroupCN, logger, retrievedClaims);
124123
}
125124
}

0 commit comments

Comments
 (0)