Search code examples
c#.netactive-directoryuserprincipal

UserPrincipal.GetAuthorizationGroups() is slow


For some reason GetAuthorizationGroups() seems to be taking around 20 seconds to return the groups. I am using this code:

UserPrincipal user;

// This takes 20 seconds
user.GetAuthorizationGroups().OfType<GroupPrincipal>().ToList();

Anyone got any ideas or is it simply a slow AD domain? (It doesn't take that long to view the groups in Outlook for instance)


Solution

  • Try doing something with the UserPrincipal object before making this call to try to remove the initialization time. If that new operation also takes a long time, then check out my other answers to similar questions.