GenericIdentity g = new GenericIdentity("Viv"); GenericPrincipal p = new GenericPrincipal(g,new string[]{"Admin","Backup"}); Thread.CurrentPrincipal = p; // System.AppDomain.CurrentDomain.SetThreadPrincipal(p); //Worksthen later (in a different form)
System.Security.Principal.IPrincipal g = System.Threading.Thread.CurrentPrincipal;
but g.Identity at this point is an empty,unauthenticated instance (as it is before setting the Thread.CurrentPrincipal). If I use the CurrentDomain.SetThreadPrincipal version above instead then g.Identity is as expected. AFAICS this is still the same thread so why the difference?