Get Groups for Current User

There are several ways of doing this but performance differs: Method 1: WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent(); foreach (var u in wi.Groups) { Console.WriteLine("{0} ", u.Value); } Method 2:   AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsIdentity wi = System.Threading.Thread.CurrentPrincipal.Identity as WindowsIdentity; foreach (var u in wi.Groups) { Console.WriteLine("{0} ", u.Value); } Method 3: using (var adContext = new PrincipalContext(ContextType.Domain, domainName))…