コード例 #1
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Guid[] currentSetIds = SecurityManagementHelper.GetUsersInTeam(_repository, Team).Select(e => e.Id).ToArray();
            Guid[] addSet        = Users.Except(currentSetIds).ToArray();
            if (addSet != null && addSet.Length > 0)
            {
                SecurityManagementHelper.AddUsersToTeam(_repository, Team, addSet);
            }
            //Remove associations which are in current and not in new
            if (Overwrite)
            {
                Guid[] removeSet = currentSetIds.Except(Users).ToArray();
                if (removeSet != null && removeSet.Length > 0)
                {
                    SecurityManagementHelper.RemoveUsersFromTeam(_repository, Team, removeSet);
                }
            }

            if (PassThru)
            {
                WriteObject(_repository.Get("team", Team));
            }
        }
コード例 #2
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Guid[] currentSetIds = SecurityManagementHelper.GetTeamsForUser(_repository, User).Select(e => e.Id).ToArray();

            Guid[] addSet = Teams.Except(currentSetIds).ToArray();
            if (addSet != null && addSet.Length > 0)
            {
                foreach (var item in addSet)
                {
                    SecurityManagementHelper.AddUsersToTeam(_repository, item, new Guid[] { User });
                }
            }
            //Remove associations which are in current and not in new
            if (Overwrite)
            {
                Guid[] removeSet = currentSetIds.Except(Teams).ToArray();
                if (removeSet != null && removeSet.Length > 0)
                {
                    foreach (var item in removeSet)
                    {
                        SecurityManagementHelper.RemoveUsersFromTeam(_repository, item, new Guid[] { User });
                    }
                }
            }

            if (PassThru)
            {
                WriteObject(_repository.Get("systemuser", User));
            }
        }
コード例 #3
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            foreach (Guid id in Team)
            {
                Guid[] currentSetIds = SecurityManagementHelper.GetUsersInTeam(_repository, id).Select(e => e.Id).ToArray();
                Guid[] removeSet     = Users;
                if (this.ParameterSetName == RemoveTeamUsersAllParameterSet)
                {
                    removeSet = currentSetIds;
                }

                if (removeSet != null && removeSet.Length > 0)
                {
                    SecurityManagementHelper.RemoveUsersFromTeam(_repository, id, removeSet);
                }
            }
        }
コード例 #4
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            foreach (Guid id in User)
            {
                Guid[] currentSetIds = SecurityManagementHelper.GetTeamsForUser(_repository, id).Select(e => e.Id).ToArray();
                Guid[] removeSet     = Teams;
                if (this.ParameterSetName == RemoveUserTeamsAllParameterSet)
                {
                    removeSet = currentSetIds;
                }

                if (removeSet != null && removeSet.Length > 0)
                {
                    foreach (var item in removeSet)
                    {
                        SecurityManagementHelper.RemoveUsersFromTeam(_repository, item, new Guid[] { id });
                    }
                }
            }
        }