I have a bit of code to get all of the AD groups for the user currently logged in:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Environment.UserDomainName);
// find a user
UserPrincipal adUser = UserPrincipal.FindByIdentity(ctx, user);
if (adUser == null)
{
Logger.Error("Could not find related Active Directory user");
return;
}
GetUserDetailsFromGroupMembership(adUser.GetGroups().Select(g => g.Name));
This will get all the groups the current user is part of on its registered domain. My username is part of the "EUR" domain, but I also have memberships on the "USA" domain. How do I also query groups in the other domains?