Error with UserPrincipal.GetAuthorizationGroups() method
I am having an issue using the GetAuthorizationGroups method of the UserPrincipal class in a web application. Using the following code, I am receiving "While trying to retrieve the authorization groups, an error (5) occurred" PrincipalContext context = new PrincipalContext(ContextType.Domain, null, "DC=MyCompany,DC=COM", "username", "password"); UserPrincipal p = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "joe.blogs"); var groups = p.GetAuthorizationGroups(); I believe this code works to an extent. When I view the context object, I can see the server and username