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; } }
private static void UpdateRecipientTypePropertiesForIntraOrg(ADUser target, int targetServerVersion) { if (MailboxMoveHelper.IsRTDRDTDefined(targetServerVersion)) { RecipientTypeDetails recipientTypeDetails = target.RecipientTypeDetails; RecipientTypeDetails recipientTypeDetails2 = (recipientTypeDetails == RecipientTypeDetails.None || recipientTypeDetails == RecipientTypeDetails.LegacyMailbox) ? MailboxMoveHelper.CalculateLegacyMailboxRTD(target) : recipientTypeDetails; target.RecipientTypeDetails = recipientTypeDetails2; if (target.RecipientDisplayType == null || recipientTypeDetails != recipientTypeDetails2) { target.RecipientDisplayType = new RecipientDisplayType?(MailboxMoveHelper.CalculateTargetRDT(target.RecipientTypeDetails, MailboxMoveHelper.IsSecurityPrincipal(target))); return; } } else { target.RecipientTypeDetails = RecipientTypeDetails.None; target.RecipientDisplayType = null; } }