public void Impersonate() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); Console.WriteLine("name:" + identity.Name); AccessHelper accessHelper = new AccessHelper(); bool result = accessHelper.Impersonate("Users", ""); if (result) { WindowsIdentity identity2 = WindowsIdentity.GetCurrent(); Console.WriteLine("name:" + identity2.Name); } accessHelper.CancelImpersonate(); }