Example #1
0
        public void ImpersonationSuccessfulLogonTest()
        {
            // For this test to work, ensure there is a generic Credential Manager entry called ImpersonationUser with working credentials
            const string workingTarget = "ImpersonationUser";
            var          currentUser   = Impersonation.CurrentUser;

            Impersonation.Impersonate(workingTarget);
            Assert.AreNotEqual(currentUser, Impersonation.CurrentUser, "Users are different after impersonating");
            Impersonation.StopImpersonating();
            Assert.AreEqual(currentUser, Impersonation.CurrentUser, "Orginal user restored after stopping impersonation");
        }