Esempio n. 1
0
 internal static void CalculateRoleConfigurationForCurrentSKU(OrganizationIdParameter organization, out RoleDefinition[] roles, out RoleNameMappingCollection nameMapping, out string[] rolesToRemove, out RoleEntry[] allAllowedRoleEntriesForSKU)
 {
     InstallCannedRbacRoles.CalculateRoleConfigurationForCurrentSKU(organization, null, out roles, out nameMapping, out rolesToRemove, out allAllowedRoleEntriesForSKU);
 }
Esempio n. 2
0
 internal static void CalculateRoleConfigurationForCurrentSKU(OrganizationIdParameter organization, ServicePlan servicePlanSettings, out RoleDefinition[] roles, out RoleNameMappingCollection nameMapping, out string[] rolesToRemove, out RoleEntry[] allAllowedRoleEntriesForSKU)
 {
     if (InstallCannedRbacRoles.isFfoEnvironment)
     {
         roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedEOPRoles_Datacenter.Definition, CannedWebServiceRoles_Datacenter.Definition);
         roles         = InstallCannedRbacRoles.MergeRoleDefinitions(roles, CannedUCCRoles_Datacenter.Definition);
         nameMapping   = InstallCannedRbacObjectsTaskBase.RoleNameMappingDatacenterR4;
         rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesDatacenter;
         allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableEOPRoleEntries_Datacenter.RoleEntries, AvailableWebServiceRoleEntries_Datacenter.RoleEntries, AvailableUCCRoleEntries_Datacenter.RoleEntries);
         return;
     }
     if (organization == null)
     {
         if (Datacenter.IsMicrosoftHostedOnly(false))
         {
             roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_Datacenter.Definition, CannedWebServiceRoles_Datacenter.Definition);
             nameMapping   = InstallCannedRbacObjectsTaskBase.RoleNameMappingDatacenterR4;
             rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesDatacenter;
             allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_Datacenter.RoleEntries, AvailableWebServiceRoleEntries_Datacenter.RoleEntries, null);
             return;
         }
         if (Datacenter.IsPartnerHostedOnly(false))
         {
             roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_Hosting.Definition, CannedWebServiceRoles_Hosting.Definition);
             nameMapping   = InstallCannedRbacObjectsTaskBase.RoleNameMappingHostingR4;
             rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesHosting;
             allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_Hosting.RoleEntries, AvailableWebServiceRoleEntries_Hosting.RoleEntries, null);
             return;
         }
         if (Datacenter.IsDatacenterDedicated(false))
         {
             roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_Dedicated.Definition, CannedWebServiceRoles_Dedicated.Definition);
             nameMapping   = InstallCannedRbacObjectsTaskBase.RoleNameMappingEnterpriseR4;
             rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesEnterprise;
             allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_Dedicated.RoleEntries, AvailableWebServiceRoleEntries_Dedicated.RoleEntries, null);
             return;
         }
         roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_Enterprise.Definition, CannedWebServiceRoles_Enterprise.Definition);
         nameMapping   = InstallCannedRbacObjectsTaskBase.RoleNameMappingEnterpriseR4;
         rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesEnterprise;
         allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_Enterprise.RoleEntries, AvailableWebServiceRoleEntries_Enterprise.RoleEntries, null);
         return;
     }
     else
     {
         if (Datacenter.IsPartnerHostedOnly(false))
         {
             roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_HostedTenant.Definition, CannedWebServiceRoles_HostedTenant.Definition);
             rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesHostedTenant;
             if (servicePlanSettings != null)
             {
                 List <string>          enabledRoleGroupRoleAssignmentFeatures = servicePlanSettings.Organization.GetEnabledRoleGroupRoleAssignmentFeatures();
                 RoleGroupRoleMapping[] definition = HostedTenant_RoleGroupDefinition.Definition;
                 List <string>          a;
                 roles         = InstallCannedRbacRoles.FilterOrgRolesByRoleGroupFilters(roles, enabledRoleGroupRoleAssignmentFeatures, definition, out a);
                 rolesToRemove = InstallCannedRbacRoles.AppendIListToarray <string>(rolesToRemove, a);
             }
             nameMapping = InstallCannedRbacObjectsTaskBase.RoleNameMappingHostedTenantR4;
             allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_HostedTenant.RoleEntries, AvailableWebServiceRoleEntries_HostedTenant.RoleEntries, null);
             return;
         }
         roles         = InstallCannedRbacRoles.MergeRoleDefinitions(CannedRoles_Tenant.Definition, CannedWebServiceRoles_Tenant.Definition);
         rolesToRemove = InstallCannedRbacObjectsTaskBase.ObsoleteRoleNamesTenant;
         if (servicePlanSettings != null)
         {
             List <string>          enabledRoleGroupRoleAssignmentFeatures2 = servicePlanSettings.Organization.GetEnabledRoleGroupRoleAssignmentFeatures();
             RoleGroupRoleMapping[] definition2 = Tenant_RoleGroupDefinition.Definition;
             List <string>          a2;
             roles         = InstallCannedRbacRoles.FilterOrgRolesByRoleGroupFilters(roles, enabledRoleGroupRoleAssignmentFeatures2, definition2, out a2);
             rolesToRemove = InstallCannedRbacRoles.AppendIListToarray <string>(rolesToRemove, a2);
         }
         nameMapping = InstallCannedRbacObjectsTaskBase.RoleNameMappingTenantR4;
         allAllowedRoleEntriesForSKU = InstallCannedRbacRoles.MergeRoleEntries(AvailableRoleEntries_Tenant.RoleEntries, AvailableWebServiceRoleEntries_Tenant.RoleEntries, null);
         return;
     }
 }
Esempio n. 3
0
        private void UpdateRolesInOrg(RoleNameMappingCollection mapping, RoleDefinition[] roleDefinitions, ServicePlan servicePlan)
        {
            TaskLogger.LogEnter();
            Container container = this.configurationSession.Read <Container>(this.rolesContainerId);

            if (container == null)
            {
                base.WriteError(new ContainerNotFoundException(this.rolesContainerId.DistinguishedName), ErrorCategory.ObjectNotFound, null);
            }
            base.LogReadObject(container);
            List <RoleDefinition>            list     = new List <RoleDefinition>();
            RoleUpgradeConfigurationSettings settings = new RoleUpgradeConfigurationSettings
            {
                AvailableRoleEntries     = this.allAllowedRoleEntriesForSKU,
                ConfigurationSession     = this.configurationSession,
                OrgContainerId           = base.OrgContainerId,
                OrganizationId           = ((null != base.CurrentOrganizationId) ? base.CurrentOrganizationId : base.ExecutingUserOrganizationId),
                Organization             = this.Organization,
                RolesContainerId         = this.rolesContainerId,
                ServicePlanSettings      = base.ServicePlanSettings,
                WriteVerbose             = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                WriteError               = new Task.TaskErrorLoggingDelegate(base.WriteError),
                WriteWarning             = new Task.TaskWarningLoggingDelegate(this.WriteWarning),
                LogReadObject            = new RoleUpgradeConfigurationSettings.LogReadObjectDelegate(base.LogReadObject),
                LogWriteObject           = new RoleUpgradeConfigurationSettings.LogWriteObjectDelegate(base.LogWriteObject),
                RemoveRoleAndAssignments = new RoleUpgradeConfigurationSettings.RemoveRoleAndAssignmentsDelegate(this.RemoveRoleAndAssignments),
                Task = this
            };

            this.RenameEndUserRolesForUnifiedRAP();
            using (List <RoleNameMapping> .Enumerator enumerator = mapping.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    RoleNameMapping map = enumerator.Current;
                    if (!map.IsSplitting && !map.IsDeprecatedRole)
                    {
                        List <RoleDefinition> list2 = roleDefinitions.ToList <RoleDefinition>().FindAll((RoleDefinition x) => x.RoleName.Equals(map.NewName));
                        if (list2 != null && list2.Count <RoleDefinition>() > 0)
                        {
                            RoleUpgrader roleUpgrader = RoleUpgraderFactory.GetRoleUpgrader(settings, map, list2[0]);
                            roleUpgrader.UpdateRole(list2[0]);
                        }
                    }
                }
            }
            List <RoleDefinition> list3 = new List <RoleDefinition>();

            foreach (RoleDefinition roleDefinition in roleDefinitions)
            {
                if (!list.Contains(roleDefinition))
                {
                    if (!string.IsNullOrEmpty(roleDefinition.ParentRoleName))
                    {
                        list3.Add(roleDefinition);
                    }
                    else
                    {
                        new List <RoleNameMapping>();
                        List <RoleNameMapping> nonRenamingMappings = mapping.GetNonRenamingMappings(roleDefinition.RoleName);
                        if (nonRenamingMappings != null)
                        {
                            using (List <RoleNameMapping> .Enumerator enumerator2 = nonRenamingMappings.GetEnumerator())
                            {
                                while (enumerator2.MoveNext())
                                {
                                    RoleNameMapping roleNameMapping = enumerator2.Current;
                                    if (roleNameMapping.NewNames == null)
                                    {
                                        throw new InvalidOperationException("Invalid MAP:" + roleNameMapping.OldName);
                                    }
                                    RoleUpgrader          roleUpgrader2 = RoleUpgraderFactory.GetRoleUpgrader(settings, roleNameMapping, roleDefinition);
                                    List <RoleDefinition> list4         = new List <RoleDefinition>();
                                    list4 = this.GetRoleDefinitionsByName(roleDefinitions, roleNameMapping.NewNames);
                                    if (roleNameMapping.IsSplitting)
                                    {
                                        list4.Add(roleDefinition);
                                    }
                                    roleUpgrader2.UpdateRoles(list4);
                                    foreach (RoleDefinition item in list4)
                                    {
                                        List <RoleNameMapping> nonRenamingMappings2 = mapping.GetNonRenamingMappings(item.RoleName);
                                        if (nonRenamingMappings2 == null)
                                        {
                                            list.Add(item);
                                        }
                                        else if (nonRenamingMappings2.Count == 1 && nonRenamingMappings2[0].Equals(roleNameMapping))
                                        {
                                            list.Add(item);
                                        }
                                    }
                                }
                                goto IL_363;
                            }
                        }
                        RoleUpgrader roleUpgrader3 = RoleUpgraderFactory.GetRoleUpgrader(settings, null, roleDefinition);
                        roleUpgrader3.UpdateRole(roleDefinition);
                    }
                }
                IL_363 :;
            }
            this.InstallCustomRoles(list3);
            TaskLogger.LogExit();
        }