//Util method public string changeIndentityToBeImpersonation(WindowsIdentity identity) { var newName = "{0}\\{1}".format(5.randomLetters(), 5.randomLetters()); //by defauld ImpersonationLevel is None Assert.AreNotEqual(identity.ImpersonationLevel, TokenImpersonationLevel.Impersonation); Assert.AreEqual (identity.ImpersonationLevel, TokenImpersonationLevel.None); //but with reflection we can change it :) identity.field("m_impersonationLevel", TokenImpersonationLevel.Impersonation); Assert.AreEqual (identity.ImpersonationLevel, TokenImpersonationLevel.Impersonation); identity.field("m_isAuthenticated", 1); Assert.IsTrue (identity.IsAuthenticated); //also change the user identity.field("m_name", newName); Assert.AreEqual (identity.Name,newName); return newName; }