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)); }
public void TestRemoteHostAdministratorUserPrivilege() { NTHost host = new NTHost(RemoteHostName); NTLocalUser user = GetObjectByName(host.GetLocalUsers(), "Administrator"); Assert.IsTrue(user.Privilege == UserPrivilege.Admin); }
public void TestLocalHostAdministratorUserPrivilege() { NTHost host = NTHost.CurrentMachine; NTLocalUser user = GetObjectByName(host.GetLocalUsers(), "Administrator"); Assert.IsTrue(user.Privilege == UserPrivilege.Admin); }
private string GenerateUserName(NTHost host) { string userName = "******"; while (ContainsObjectByName(host.GetLocalUsers(), userName)) { userName = "******" + Guid.NewGuid().ToString().Substring(0, 4); } return(userName); }
public void TestLocalHostGetGuest() { NTHost host = NTHost.CurrentMachine; Assert.IsTrue( ContainsSid( new SecurityIdentifier(WellKnownSidType.AccountGuestSid, host.SID), host.GetLocalUsers() ) ); }
public void TestRemoteHostGetGuest() { NTHost host = new NTHost(RemoteHostName); Assert.IsTrue( ContainsSid( new SecurityIdentifier(WellKnownSidType.AccountGuestSid, host.SID), host.GetLocalUsers() ) ); }
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(); } }
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(); } }
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(); } }
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(); }
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(); } }
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(); } }
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(); } }