Пример #1
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));
            }
        }
Пример #2
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Guid[] roleIds        = Roles;
            Guid   businessUnitId = BusinessUnit ?? SecurityManagementHelper.GetDefaultBusinessUnitId(_repository);

            Entity newUser = new Entity("systemuser")
            {
                Attributes = new AttributeCollection()
            };

            newUser.Attributes.Add("domainname", UserName);
            newUser.Attributes.Add("firstname", Firstname);
            newUser.Attributes.Add("lastname", Lastname);
            newUser.Attributes.Add("accessmode", new OptionSetValue((int)Access));
            newUser.Attributes.Add("caltype", new OptionSetValue((int)License));
            newUser.Attributes.Add("businessunitid", new EntityReference("businessunit", businessUnitId));

            Guid newUserId = _repository.Add(newUser);

            SecurityManagementHelper.LinkPrincipalRoles(_repository, "systemuser", newUserId, "role", roleIds);

            if (PassThru)
            {
                WriteObject(_repository.Get("systemuser", newUserId));
            }
        }
Пример #3
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Guid businessUnitId = BusinessUnit ?? SecurityManagementHelper.GetDefaultBusinessUnitId(_repository);

            Entity newRole = new Entity("role")
            {
                Attributes = new AttributeCollection()
            };

            newRole.Attributes.Add("name", Name);
            newRole.Attributes.Add("businessunitid", new EntityReference("businessunit", businessUnitId));

            Guid newRoleId = _repository.Add(newRole);

            if (PassThru)
            {
                WriteObject(_repository.Get("role", newRoleId));
            }
        }