コード例 #1
0
        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());
        }
コード例 #2
0
        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;
        }
コード例 #3
0
ファイル: Prison.cs プロジェクト: UhuruSoftware/vcap-dotnet
        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;
        }