Beispiel #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));
            }
        }
Beispiel #2
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Guid[] userIds        = Users;
            Guid   businessUnitId = BusinessUnit ?? SecurityManagementHelper.GetDefaultBusinessUnitId(_repository);

            Entity newTeam = new Entity("team")
            {
                Attributes = new AttributeCollection()
            };

            newTeam.Attributes.Add("name", Name);
            newTeam.Attributes.Add("teamtype", new OptionSetValue((int)TeamType));
            newTeam.Attributes.Add("administratorid", new EntityReference("systemuser", Administrator));
            newTeam.Attributes.Add("businessunitid", new EntityReference("businessunit", businessUnitId));
            if (!string.IsNullOrWhiteSpace(Description))
            {
                newTeam.Attributes.Add("description", Description);
            }

            Guid newTeamId = _repository.Add(newTeam);

            if (Users != null && Users.Length != 0)
            {
                SecurityManagementHelper.AddUsersToTeam(_repository, newTeamId, Users);
            }

            if (PassThru)
            {
                WriteObject(_repository.Get("team", newTeamId));
            }
        }
        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));
            }
        }