protected void RenameExistingRole(RoleNameMapping mapping, string suffix) { ExTraceGlobals.AccessCheckTracer.TraceFunction <bool>(20005L, "-->RenameExistingRole: Mapping Is Null = {0}", mapping == null); if (mapping == null) { return; } string text = string.IsNullOrEmpty(suffix) ? mapping.OldName : (mapping.OldName + suffix); ExchangeRole exchangeRole = this.settings.ConfigurationSession.Read <ExchangeRole>(this.settings.RolesContainerId.GetChildId(text)); if (exchangeRole != null) { this.settings.LogReadObject(exchangeRole); string text2 = string.IsNullOrEmpty(suffix) ? mapping.NewName : (mapping.NewName + suffix); exchangeRole.SetId(this.settings.RolesContainerId.GetChildId(text2)); this.SaveRoleAndSuggestCleanupOnFailure(exchangeRole); ExTraceGlobals.AccessCheckTracer.TraceFunction <string, string>(20005L, "<--RenameExistingRole: Role Renamed. oldName = {0}, NewName = {1}", text, text2); } }
public static bool CanUpgrade(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping, RoleDefinition roleDefinition, out RoleUpgrader roleUpgrader) { ExTraceGlobals.AccessCheckTracer.TraceFunction <string>(20006L, "-->NonDeprecatedRoleUpgrader.CanUpgrade: roleName = {0}", roleDefinition.RoleName); bool flag = false; roleUpgrader = null; if (settings.Organization == null) { flag = true; } else if (!roleDefinition.IsEndUserRole || !settings.ServicePlanSettings.Organization.PerMBXPlanRoleAssignmentPolicyEnabled) { flag = true; } flag = (flag && (roleNameMapping == null || (!roleNameMapping.IsDeprecatedRole && !roleNameMapping.IsSplitting))); if (flag) { roleUpgrader = new NonDeprecatedRoleUpgrader(settings, roleNameMapping); } ExTraceGlobals.AccessCheckTracer.TraceFunction <bool>(20006L, "<--NonDeprecatedRoleUpgrader.CanUpgrade: canUpgrade = {0}", flag); return(flag); }
protected ExchangeRole CreateOrUpdateRole(RoleNameMapping mapping, RoleDefinition definition, List <string> enabledPermissionFeatures, string suffix, string mailboxPlanIndex) { ExTraceGlobals.AccessCheckTracer.TraceFunction(20005L, "-->CreateOrUpdateRole: RoleDefinition = {0}, enabledPermissionFeatures is Null = {1}, suffix = {2}, mailboxPlanIndex = {3}", new object[] { definition.RoleName, enabledPermissionFeatures == null, string.IsNullOrEmpty(suffix) ? string.Empty : suffix, string.IsNullOrEmpty(mailboxPlanIndex) ? string.Empty : mailboxPlanIndex }); this.RenameExistingRole(mapping, suffix); ExchangeRole exchangeRole = definition.GenerateRole(enabledPermissionFeatures, this.settings.RolesContainerId, suffix, mailboxPlanIndex); if (exchangeRole.RoleEntries.Count > 0) { ExchangeRole exchangeRole2 = this.settings.ConfigurationSession.Read <ExchangeRole>(exchangeRole.Id); if (exchangeRole2 != null) { this.settings.LogReadObject(exchangeRole2); this.UpdateCannedRole(exchangeRole2, exchangeRole, definition); exchangeRole = exchangeRole2; ExTraceGlobals.AccessCheckTracer.TraceFunction(20005L, "<--CreateOrUpdateRole: Role Updated"); } else { exchangeRole.OrganizationId = this.settings.OrganizationId; this.SaveRoleAndSuggestCleanupOnFailure(exchangeRole); ExTraceGlobals.AccessCheckTracer.TraceFunction(20005L, "<--CreateOrUpdateRole: New Role created"); this.CreateDCSafeRoleIfNeeded(exchangeRole, definition); } } else { ExTraceGlobals.AccessCheckTracer.TraceFunction(20005L, "<--CreateOrUpdateRole: No Role created"); this.settings.RemoveRoleAndAssignments(exchangeRole.Id); exchangeRole = null; } return(exchangeRole); }
protected ExchangeRole CreateOrUpdateRole(RoleNameMapping mapping, RoleDefinition definition, List <string> enabledPermissionFeatures) { return(this.CreateOrUpdateRole(mapping, definition, enabledPermissionFeatures, null, null)); }
protected RoleUpgrader(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping) { this.settings = settings; this.roleNameMapping = roleNameMapping; }
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(); }
protected SplitRoleUpgrader(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping) : base(settings, roleNameMapping) { }
public static RoleUpgrader GetRoleUpgrader(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping, RoleDefinition roleDefinition) { RoleUpgrader result = null; foreach (RoleUpgraderFactory.CanUpgradeRoleDelegate canUpgradeRoleDelegate in RoleUpgraderFactory.knownUpgrades) { if (canUpgradeRoleDelegate(settings, roleNameMapping, roleDefinition, out result)) { break; } } return(result); }
protected NonDeprecatedRoleUpgrader(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping) : base(settings, roleNameMapping) { }
protected void CreateOrUpdateRoles(RoleNameMapping mapping, List <RoleDefinition> roleDefinitions, List <string> enabledPermissionFeatures) { this.CreateOrUpdateRoles(mapping, roleDefinitions, enabledPermissionFeatures, null, null); }
protected MailboxPlanRoleUpgrader(RoleUpgradeConfigurationSettings settings, RoleNameMapping roleNameMapping) : base(settings, roleNameMapping) { }