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)); } }
protected override void ExecuteCmdlet() { base.ExecuteCmdlet(); foreach (Guid id in User) { WriteObject(SecurityManagementHelper.GetTeamsForUser(_repository, id), true); } }
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 }); } } } }
protected override void ExecuteCmdlet() { base.ExecuteCmdlet(); WriteObject(SecurityManagementHelper.GetTeamsForUser(_repository, User), true); }