Example #1
0
        public void TestLocalUserCreateDelete()
        {
            NTHost host = NTHost.CurrentMachine;
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            Assert.IsNotNull(user);
            Assert.IsTrue(ContainsObjectByName(host.GetLocalUsers(), userName));
            user.Delete();
            Assert.IsFalse(ContainsObjectByName(host.GetLocalUsers(), userName));
        }
Example #2
0
        public void TestRemoteHostAdministratorUserPrivilege()
        {
            NTHost      host = new NTHost(RemoteHostName);
            NTLocalUser user = GetObjectByName(host.GetLocalUsers(), "Administrator");

            Assert.IsTrue(user.Privilege == UserPrivilege.Admin);
        }
Example #3
0
        public void TestLocalHostAdministratorUserPrivilege()
        {
            NTHost      host = NTHost.CurrentMachine;
            NTLocalUser user = GetObjectByName(host.GetLocalUsers(), "Administrator");

            Assert.IsTrue(user.Privilege == UserPrivilege.Admin);
        }
Example #4
0
        private string GenerateUserName(NTHost host)
        {
            string userName = "******";

            while (ContainsObjectByName(host.GetLocalUsers(), userName))
            {
                userName = "******" + Guid.NewGuid().ToString().Substring(0, 4);
            }
            return(userName);
        }
Example #5
0
        public void TestLocalHostGetGuest()
        {
            NTHost host = NTHost.CurrentMachine;

            Assert.IsTrue(
                ContainsSid(
                    new SecurityIdentifier(WellKnownSidType.AccountGuestSid, host.SID),
                    host.GetLocalUsers()
                    )
                );
        }
Example #6
0
        public void TestRemoteHostGetGuest()
        {
            NTHost host = new NTHost(RemoteHostName);

            Assert.IsTrue(
                ContainsSid(
                    new SecurityIdentifier(WellKnownSidType.AccountGuestSid, host.SID),
                    host.GetLocalUsers()
                    )
                );
        }
Example #7
0
        public void TestLocalUserUpdateLastLogon()
        {
            NTHost   host  = NTHost.CurrentMachine;
            DateTime value = DateTime.MinValue;
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                Assert.AreEqual(value, user.LastLogon);
            } finally {
                user.Delete();
            }
        }
Example #8
0
        public void TestLocalGetUserUnitsPerWeek()
        {
            NTHost host  = NTHost.CurrentMachine;
            uint   value = 5;
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
                user.UnitsPerWeek = value;
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                Assert.AreEqual(user.UnitsPerWeek, value);
            } finally {
                user.Delete();
            }
        }
Example #9
0
        public void TestLocalUserUpdateScriptPath()
        {
            NTHost host  = NTHost.CurrentMachine;
            string value = Process.GetCurrentProcess().StartInfo.FileName;
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
                user.ScriptPath = value;
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                Assert.AreEqual(user.ScriptPath, value);
            } finally {
                user.Delete();
            }
        }
Example #10
0
        public void TestLocalUserUpdateLogonHours()
        {
            NTHost host = NTHost.CurrentMachine;

            byte[] value = new byte[21] {
                1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1
            };
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            user.LogonHours = value;
            user.Update();
            user = GetObjectByName(host.GetLocalUsers(), userName);
            CollectionAssert.AreEqual(user.LogonHours, value);
            user.Delete();
        }
Example #11
0
        public void TestLocalUserUpdateHomeDirectory()
        {
            NTHost host  = NTHost.CurrentMachine;
            string value = "c:\\";
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
                user.HomeDirectory = value;
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                Assert.AreEqual(user.HomeDirectory, value);
            } finally {
                user.Delete();
            }
        }
Example #12
0
        public void TestLocalUserGetWorkstations()
        {
            NTHost host = NTHost.CurrentMachine;

            string[] value = new string[] { "W1", "w2" };
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
                user.Workstations = value;
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                CollectionAssert.AreEqual(user.Workstations, value);
            } finally {
                user.Delete();
            }
        }
Example #13
0
        public void TestLocalUserUpdateMaxStorage()
        {
            NTHost host  = NTHost.CurrentMachine;
            uint   value = 1000;
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            try {
//                user.Flags |= UserFlags.
                user.MaxStorage = value;
                user.Update();
                user = GetObjectByName(host.GetLocalUsers(), userName);
                Assert.AreEqual(value, user.MaxStorage);
            } finally {
                user.Delete();
            }
        }