public static void Verify(string user)
 {
     if (!UserRightsAssignmentPolicies.UserHasPrivilege(
             UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
             user))
     {
         throw new PrisonException(
                   "User {0} does not have the {1} privilege",
                   user,
                   UserRightsAssignmentPolicies.ReplaceTokenPrivilege);
     }
 }
Esempio n. 2
0
        public void TestLocalServiceReplaceTokenPrivilege()
        {
            // Arrange
            string userName = "******";

            // Act
            bool hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege(
                UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                userName);

            // Assert
            Assert.IsTrue(hasPrivilege);
        }
Esempio n. 3
0
        public void TestSystemNoReplaceTokenPrivilege()
        {
            // Arrange
            string userName = "******";

            // Act
            bool hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege(
                UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                userName);

            // Assert
            Assert.IsFalse(hasPrivilege);
        }
Esempio n. 4
0
        public void TestGrantAndRevokeTokenPrivilege()
        {
            // Arrange
            PrisonUser newUser = new PrisonUser("prtst");

            try
            {
                newUser.Create();
                bool hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege(
                    UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                    newUser.UserName);
                Assert.IsFalse(hasPrivilege);

                // Act
                UserRightsAssignmentPolicies.GrantPrivilegeToUser(
                    UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                    newUser.UserName);
                hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege(
                    UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                    newUser.UserName);

                // Assert
                Assert.IsTrue(hasPrivilege);

                // Act
                UserRightsAssignmentPolicies.RevokePrivilegeToUser(
                    UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                    newUser.UserName);
                hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege(
                    UserRightsAssignmentPolicies.ReplaceTokenPrivilege,
                    newUser.UserName);

                // Assert
                Assert.IsFalse(hasPrivilege);
            }
            finally
            {
                newUser.Delete();
            }
        }