public void Lockdown(PrisonRules prisonRules) { if (this.isLocked) { throw new InvalidOperationException("This prison is already locked."); } Logger.Debug("Locking down prison {0}", this.ID); Directory.CreateDirectory(prisonRules.PrisonHomePath); this.prisonRules = prisonRules; if (prisonRules.CellType != RuleType.None) { foreach (Type cellType in cellTypes) { Rule cell = (Rule)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(); // InitializeSystemVirtualAddressSpaceQuotas(); this.InitializeJobObject(); // Lock all cells foreach (Rule cell in this.prisonCells) { if (cell.GetFlag() != RuleType.WindowStation) { cell.Apply(this); } } this.CreateUserProfile(); // Directory.CreateDirectory(prisonRules.PrisonHomePath); this.ChangeProfilePath(Path.Combine(prisonRules.PrisonHomePath, "profile")); // RunGuard(); this.isLocked = true; this.Save(); }
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()); }