I've got some code which checks Active Directory
for all groups that a user is a member of, this works fine locally in my development environment but doesn't when I release to the Test system.
A fellow workmate has suggested that maybe the account that the application pool runs under in IIS
is unable to poll Active Directory
. Would this be the case? What could be causing no groups to be returned?
When I run my code locally I am able to retrieve the list, but Test comes back empty. There are no errors thrown at all.
Example code, where I change "LIVE" to "TEST" as we have a multi-domain network, but neither works:
UserPrincipal user = UserPrincipal.Current;
if (user != null)
{
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "TEST");
List<Principal> groupResults = user.GetGroups(principalContext).ToList();
}