private static void UpdateRecipientTypeProperties(ADUser source, int sourceServerVersion, ADUser target, int targetServerVersion, MailboxMoveHelper.Scenario scenario, MailboxMoveType moveType, MailboxMoveTransition transition) { if (!MailboxMoveHelper.IsMovingPrimary(moveType)) { return; } if (scenario == MailboxMoveHelper.Scenario.CrossPremiseOnboarding && transition == MailboxMoveTransition.UpdateSourceUser && MailboxMoveHelper.IsRemoteMailboxTypeDefined(sourceServerVersion)) { source.RemoteRecipientType = MailboxMoveHelper.CalculateSourceRRT(source.RecipientTypeDetails); } else if (scenario == MailboxMoveHelper.Scenario.CrossPremiseOffboarding && transition == MailboxMoveTransition.UpdateTargetUser && MailboxMoveHelper.IsRemoteMailboxTypeDefined(targetServerVersion)) { target.RemoteRecipientType = RemoteRecipientType.Migrated; } if (transition == MailboxMoveTransition.UpdateTargetUser) { RecipientTypeDetails recipientTypeDetails = (source.RecipientTypeDetails != RecipientTypeDetails.None) ? source.RecipientTypeDetails : MailboxMoveHelper.CalculateLegacyMailboxRTD(source); if (target.MasterAccountSid == null && MailboxMoveHelper.IsResourceOrShared(recipientTypeDetails)) { target.MasterAccountSid = new SecurityIdentifier(WellKnownSidType.SelfSid, null); } if (MailboxMoveHelper.IsRTDRDTDefined(targetServerVersion)) { target.RecipientTypeDetails = MailboxMoveHelper.CalculateTargetRTD(recipientTypeDetails, MailboxMoveHelper.IsLinkedAccount(target)); target.RecipientDisplayType = new RecipientDisplayType?(MailboxMoveHelper.CalculateTargetRDT(target.RecipientTypeDetails, MailboxMoveHelper.IsSecurityPrincipal(target))); } else { target.RecipientTypeDetails = RecipientTypeDetails.None; target.RecipientDisplayType = null; } } if (transition == MailboxMoveTransition.UpdateSourceUser) { if (MailboxMoveHelper.IsRTDRDTDefined(sourceServerVersion)) { source.RecipientDisplayType = new RecipientDisplayType?(MailboxMoveHelper.CalculateSourceRDT(source.RecipientTypeDetails, MailboxMoveHelper.IsACLableSyncedObjectEnabled(source, scenario) && MailboxMoveHelper.IsSecurityPrincipal(source))); source.RecipientTypeDetails = MailboxMoveHelper.CalculateSourceRTD(source, sourceServerVersion, scenario); return; } source.RecipientTypeDetails = RecipientTypeDetails.None; source.RecipientDisplayType = null; } }
public static void UpdateRecipientTypeProperties(ADUser source, UserHoster sourceHoster, int sourceServerVersion, ADUser target, UserHoster targetHoster, int targetServerVersion, MailboxMoveType moveType, MailboxMoveTransition transition) { if (target == null) { throw new ArgumentNullException("target"); } if (transition == MailboxMoveTransition.IntraOrg) { if (MailboxMoveHelper.IsMovingPrimary(moveType)) { MailboxMoveHelper.UpdateRecipientTypePropertiesForIntraOrg(target, targetServerVersion); } return; } if (source == null) { throw new ArgumentNullException("source"); } if (!source.propertyBag.Contains(ADUserSchema.UserAccountControl)) { throw new ArgumentException("Source ADUser missed property: UserAccountControl", "source"); } if (!target.propertyBag.Contains(ADUserSchema.UserAccountControl)) { throw new ArgumentException("Target ADUser missed property: UserAccountControl", "target"); } if (transition == MailboxMoveTransition.UpdateSourceUser && sourceServerVersion == 0) { throw new ArgumentException("Version of source mailbox server is required", "sourceServerVersion"); } if (transition == MailboxMoveTransition.UpdateTargetUser && targetServerVersion == 0) { throw new ArgumentException("Version of target mailbox server is required", "targetServerVersion"); } MailboxMoveHelper.Scenario scenario = MailboxMoveHelper.GetScenario(sourceHoster, targetHoster); if (scenario == MailboxMoveHelper.Scenario.CrossPremiseOnboarding && sourceServerVersion < Server.E14SP1MinVersion) { sourceServerVersion = Server.E14SP1MinVersion; } MailboxMoveHelper.UpdateRecipientTypeProperties(source, sourceServerVersion, target, targetServerVersion, scenario, moveType, transition); }