UserPrincipal GetGroups is very slow on a Windows 2008 server

I have a way to get user groups in Windows 2008 AD.

using (var domainContext = new PrincipalContext(ContextType.Domain, domain, login, pwd)) { using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, samAccountName)) { if (foundUser != null) { var grs = foundUser.GetGroups(domainContext); .... } } } 

The package works fine on Windows Server 2003 and XP, but I have a very slow response on Windows Server 2008 with this line:

 foundUser.GetGroups(domainContext); 
  • Windows Server 2003 and XP: call takes 100 ms
  • Windows Server 2008: call takes 2500 ms

Can you help me with this problem?

Many thanks

+6
source share

All Articles