In a Web API controller I needed to determine the role membership using an AD group that contained members from multiple domains in another forest.
this.RequestContext.Principal.IsInRole(roleName)
returned false and no indication of an error could be found. The code above did work with other AD groups, though. I then modified the code to loop through the group in question and received an exception.
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, roleName);
if (group != null)
{
foreach (Principal p in group.GetMembers())
{
if (p != null && currentUserPrincipal.UserPrincipalName == p.UserPrincipalName)
{
roles.Add(roleName);
break;
}
}
}
The specified directory service attribute or value does not exist.
I determined it was the exception was being thrown on a group member from a specific domain. I removed said individual and code executed normally. I added another account form the same domain as the first and the error returned.