コード例 #1
0
        public void TestLocalPersistUserPassword()
        {
            NTHost host  = NTHost.CurrentMachine;
            string value = "AbCn1122CeF123";
            // find a unique user name
            string      userName = GenerateUserName(host);
            NTLocalUser user     = host.CreateLocalUser(userName, "P4ssw0rd123");

            user.Password = value;
            user.Update();
            user.Delete();
        }
コード例 #2
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();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
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();
        }
コード例 #6
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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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();
            }
        }