protected override void WriteResult(IConfigurable dataObject) { RoleAssignmentPolicy roleAssignmentPolicy = (RoleAssignmentPolicy)dataObject; Result <ExchangeRoleAssignment>[] roleAssignmentResults; if (base.SharedConfiguration != null) { SharedConfiguration sharedConfiguration = base.SharedConfiguration; IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 553, "WriteResult", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxPolicies\\RoleAssignmentPolicyTasks.cs"); roleAssignmentResults = tenantOrTopologyConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[] { sharedConfiguration.GetSharedRoleAssignmentPolicy() }, false); roleAssignmentPolicy.SharedConfiguration = sharedConfiguration.SharedConfigurationCU.Id; } else { roleAssignmentResults = this.ConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[] { roleAssignmentPolicy.Id }, false); } roleAssignmentPolicy.PopulateRoles(roleAssignmentResults); base.WriteResult(roleAssignmentPolicy); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser user = (ADUser)dataObject; SharedConfiguration sharedConfig = null; if (SharedConfiguration.IsDehydratedConfiguration(user.OrganizationId) || (SharedConfiguration.GetSharedConfigurationState(user.OrganizationId) & SharedTenantConfigurationState.Static) != SharedTenantConfigurationState.UnSupported) { sharedConfig = base.ProvisioningCache.TryAddAndGetOrganizationData <SharedConfiguration>(CannedProvisioningCacheKeys.MailboxSharedConfigCacheKey, user.OrganizationId, () => SharedConfiguration.GetSharedConfiguration(user.OrganizationId)); } if (null != user.MasterAccountSid) { user.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(user.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); user.ResetChangeTracking(); } Mailbox mailbox = new Mailbox(user); mailbox.propertyBag.SetField(MailboxSchema.Database, ADObjectIdResolutionHelper.ResolveDN(mailbox.Database)); if (sharedConfig != null) { mailbox.SharedConfiguration = sharedConfig.SharedConfigId.ConfigurationUnit; if (mailbox.RoleAssignmentPolicy == null) { mailbox.RoleAssignmentPolicy = base.ProvisioningCache.TryAddAndGetOrganizationData <ADObjectId>(CannedProvisioningCacheKeys.MailboxRoleAssignmentPolicyCacheKey, user.OrganizationId, () => sharedConfig.GetSharedRoleAssignmentPolicy()); } } else if (mailbox.RoleAssignmentPolicy == null && !mailbox.ExchangeVersion.IsOlderThan(MailboxSchema.RoleAssignmentPolicy.VersionAdded)) { ADObjectId defaultRoleAssignmentPolicy = RBACHelper.GetDefaultRoleAssignmentPolicy(user.OrganizationId); if (defaultRoleAssignmentPolicy != null) { mailbox.RoleAssignmentPolicy = defaultRoleAssignmentPolicy; } } if (mailbox.SharingPolicy == null && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.SharingPolicy)) { mailbox.SharingPolicy = base.GetDefaultSharingPolicyId(user, sharedConfig); } if (mailbox.RetentionPolicy == null && mailbox.ShouldUseDefaultRetentionPolicy && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetentionPolicy)) { mailbox.RetentionPolicy = base.GetDefaultRetentionPolicyId(user, sharedConfig); } if (mailbox.Database != null && mailbox.UseDatabaseRetentionDefaults) { this.SetDefaultRetentionValues(mailbox); } mailbox.AdminDisplayVersion = Microsoft.Exchange.Data.Directory.SystemConfiguration.Server.GetServerVersion(mailbox.ServerName); return(mailbox); }