示例#1
0
        private PowerShellResults <ManagementScopeRow> GetManagementScope(string managementScope, PowerShellResults <AdminRoleGroupRow> results)
        {
            PowerShellResults <ManagementScopeRow> result = null;

            if (!string.IsNullOrEmpty(managementScope) && !ManagementScopeRow.IsDefaultScope(managementScope))
            {
                ManagementScopes managementScopes = new ManagementScopes();
                Identity         identity         = new Identity(managementScope, managementScope);
                result = results.MergeErrors <ManagementScopeRow>(managementScopes.GetObject(identity));
            }
            return(result);
        }
示例#2
0
        public PowerShellResults <AdminRoleGroupRow> NewObject(NewAdminRoleGroupParameter properties)
        {
            properties.FaultIfNull();
            PowerShellResults <AdminRoleGroupRow> powerShellResults = new PowerShellResults <AdminRoleGroupRow>();

            if (properties.IsScopeModified)
            {
                if (properties.IsOrganizationalUnit)
                {
                    if (string.IsNullOrEmpty(properties.ManagementScopeId))
                    {
                        throw new FaultException(Strings.InvalidOrganizationalUnit(properties.ManagementScopeId));
                    }
                    OrganizationalUnits organizationalUnits = new OrganizationalUnits();
                    Identity            identity            = new Identity(properties.ManagementScopeId, properties.ManagementScopeId);
                    PowerShellResults <ExtendedOrganizationalUnit> powerShellResults2 = powerShellResults.MergeErrors <ExtendedOrganizationalUnit>(organizationalUnits.GetObject(identity));
                    if (powerShellResults.Failed)
                    {
                        return(powerShellResults);
                    }
                    ExtendedOrganizationalUnit value = powerShellResults2.Value;
                    properties.RecipientOrganizationalUnitScope = new Identity(value.Id, value.Name);
                }
                else
                {
                    PowerShellResults <ManagementScopeRow> managementScope = this.GetManagementScope(properties.ManagementScopeId, powerShellResults);
                    if (powerShellResults.Failed)
                    {
                        return(powerShellResults);
                    }
                    if (managementScope != null && managementScope.SucceededWithValue)
                    {
                        ManagementScopeRow value2 = managementScope.Value;
                        if (value2.ScopeRestrictionType == ScopeRestrictionType.RecipientScope)
                        {
                            properties.RecipientWriteScope = value2.Identity;
                        }
                        else if (value2.ScopeRestrictionType == ScopeRestrictionType.ServerScope)
                        {
                            properties.ConfigWriteScope = value2.Identity;
                        }
                    }
                }
            }
            powerShellResults = base.NewObject <AdminRoleGroupRow, NewAdminRoleGroupParameter>("New-RoleGroup", properties);
            if (powerShellResults.Succeeded && powerShellResults.HasWarnings)
            {
                powerShellResults.Warnings = null;
            }
            return(powerShellResults);
        }
示例#3
0
        private PowerShellResults <AdminRoleGroupRow> UpdateRoleAssignments(Delta <Identity> delta, Identity identity, SetAdminRoleGroupParameter properties, PowerShellResults <AdminRoleGroupRow> results)
        {
            ManagementScopeRow        managementScopeRow        = properties.ManagementScopeRow;
            ManagementRoleAssignments roleAssignmentsWebService = new ManagementRoleAssignments();

            results = this.SetRoleAssignments(delta.UnchangedObjects, roleAssignmentsWebService, identity, managementScopeRow, properties.OrganizationalUnitRow, results);
            if (results.Failed)
            {
                return(results);
            }
            results = this.AddRoleAssignments(delta.AddedObjects, roleAssignmentsWebService, identity, managementScopeRow, properties.OrganizationalUnitRow, results);
            if (results.Failed)
            {
                return(results);
            }
            results = this.RemoveRoleAssignments(delta.RemovedObjects, roleAssignmentsWebService, identity, results);
            if (results.Failed)
            {
                return(results);
            }
            return(results);
        }
示例#4
0
        private SetManagementRoleAssignment SetScopeInfoInParameter(Identity roleIdentity, SetManagementRoleAssignment param, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results)
        {
            SetManagementRoleAssignment setManagementRoleAssignment = param;

            if (setManagementRoleAssignment == null)
            {
                setManagementRoleAssignment = new SetManagementRoleAssignment();
            }
            if (ouRow != null || scopeRow != null)
            {
                if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.ServerScope)
                {
                    setManagementRoleAssignment.RecipientWriteScope = null;
                    setManagementRoleAssignment.ConfigWriteScope    = scopeRow.Identity;
                }
                else
                {
                    if (!Util.IsDataCenter)
                    {
                        if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.DatabaseScope)
                        {
                            setManagementRoleAssignment.ConfigWriteScope = scopeRow.Identity;
                        }
                        else
                        {
                            setManagementRoleAssignment.ConfigWriteScope = null;
                        }
                    }
                    if (ouRow != null)
                    {
                        setManagementRoleAssignment.OrganizationalUnit = new Identity(ouRow.Id, ouRow.Name);
                    }
                    else if (scopeRow != null && scopeRow.ScopeRestrictionType == ScopeRestrictionType.RecipientScope)
                    {
                        setManagementRoleAssignment.RecipientWriteScope = scopeRow.Identity;
                    }
                }
            }
            return(setManagementRoleAssignment);
        }
示例#5
0
 private PowerShellResults <AdminRoleGroupRow> SetRoleAssignments(IEnumerable <Identity> unchangedRoles, ManagementRoleAssignments roleAssignmentsWebService, Identity identity, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results)
 {
     if ((ouRow != null || scopeRow != null) && unchangedRoles != null)
     {
         foreach (Identity roleIdentity in unchangedRoles)
         {
             PowerShellResults <ManagementRoleAssignment> roleAssignments = this.GetRoleAssignments(roleIdentity, identity, roleAssignmentsWebService);
             if (roleAssignments.Failed)
             {
                 results.MergeErrors <ManagementRoleAssignment>(roleAssignments);
                 return(results);
             }
             SetManagementRoleAssignment properties = this.SetScopeInfoInParameter(roleIdentity, null, scopeRow, ouRow, results);
             if (results.Failed)
             {
                 return(results);
             }
             ManagementRoleAssignment[] output = roleAssignments.Output;
             foreach (ManagementRoleAssignment managementRoleAssignment in output)
             {
                 if (managementRoleAssignment.DelegationType == RoleAssignmentDelegationType.Regular)
                 {
                     results.MergeErrors <ManagementRoleAssignment>(roleAssignmentsWebService.SetObject(managementRoleAssignment.Identity, properties));
                     if (results.Failed)
                     {
                         return(results);
                     }
                 }
             }
         }
         return(results);
     }
     return(results);
 }
示例#6
0
 private PowerShellResults <AdminRoleGroupRow> AddRoleAssignments(IEnumerable <Identity> addedRoles, ManagementRoleAssignments roleAssignmentsWebService, Identity identity, ManagementScopeRow scopeRow, ExtendedOrganizationalUnit ouRow, PowerShellResults <AdminRoleGroupRow> results)
 {
     if (addedRoles != null)
     {
         foreach (Identity identity2 in addedRoles)
         {
             NewManagementRoleAssignment newManagementRoleAssignment = new NewManagementRoleAssignment();
             newManagementRoleAssignment.Role          = identity2;
             newManagementRoleAssignment.SecurityGroup = identity.RawIdentity;
             this.SetScopeInfoInParameter(identity2, newManagementRoleAssignment, scopeRow, ouRow, results);
             if (results.Failed)
             {
                 return(results);
             }
             results.MergeErrors <ManagementRoleAssignment>(roleAssignmentsWebService.NewObject(newManagementRoleAssignment));
         }
         return(results);
     }
     return(results);
 }