コード例 #1
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));
            }
        }
コード例 #2
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            foreach (Guid id in User)
            {
                WriteObject(SecurityManagementHelper.GetTeamsForUser(_repository, id), true);
            }
        }
コード例 #3
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 });
                    }
                }
            }
        }
コード例 #4
0
 protected override void ExecuteCmdlet()
 {
     base.ExecuteCmdlet();
     WriteObject(SecurityManagementHelper.GetTeamsForUser(_repository, User), true);
 }