public static PrisonUser[] ListUsers() { List <PrisonUser> result = new List <PrisonUser>(); string[] allUsers = WindowsUsersAndGroups.GetUsers(); foreach (string user in allUsers) { if (user.StartsWith(PrisonUser.GlobalPrefix)) { string password = (string)Persistence.ReadValue("prison_users", user); // If we can't find the user's password, ignore the account if (!string.IsNullOrWhiteSpace(password)) { result.Add(new PrisonUser(PrisonUser.GetUsernamePrefix(user), user, password, true)); } } } return(result.ToArray()); }
public void Lockdown(PrisonRules prisonRules) { if (this.isLocked) { throw new InvalidOperationException("This prison is already locked."); } this.prisonRules = prisonRules; if (prisonRules.CellType != CellType.None) { foreach (Type cellType in cellTypes) { Cell cell = (Cell)cellType.GetConstructor(Type.EmptyTypes).Invoke(null); if (CellEnabled(cell.GetFlag())) { prisonCells.Add(cell); } } } // Create the Windows User this.user = new PrisonUser(this.Tag); this.user.Create(); // Create the JobObject this.jobObject = new JobObject(this.user.Username); this.jobObject.KillProcessesOnJobClose = true; // Lock all cells foreach (Cell cell in this.prisonCells) { cell.Lockdown(this); } this.isLocked = true; }
public void Lockdown(PrisonRules prisonRules) { if (this.isLocked) { throw new InvalidOperationException("This prison is already locked."); } this.prisonRules = prisonRules; if (prisonRules.CellType != CellType.None) { foreach (Type cellType in cellTypes) { Cell cell = (Cell)cellType.GetConstructor(Type.EmptyTypes).Invoke(null); if (CellEnabled(cell.GetFlag())) { prisonCells.Add(cell); } } } // Create the Windows User this.user = new PrisonUser(this.Tag); this.user.Create(); // Create the JobObject this.jobObject = new JobObject(this.user.Username); this.jobObject.KillProcessesOnJobClose = true; // Lock all cells foreach (Cell cell in this.prisonCells) { cell.Lockdown(this); } this.isLocked = true; }