private static RecipientTypeDetails CalculateSourceRTD(ADUser source, int sourceServerVersion, MailboxMoveHelper.Scenario scenario) { RecipientTypeDetails result; if (scenario == MailboxMoveHelper.Scenario.CrossPremiseOnboarding && MailboxMoveHelper.IsRemoteMailboxTypeDefined(sourceServerVersion)) { RecipientTypeDetails recipientTypeDetails = source.RecipientTypeDetails; if (recipientTypeDetails <= RecipientTypeDetails.RoomMailbox) { if (recipientTypeDetails <= RecipientTypeDetails.SharedMailbox) { if (recipientTypeDetails < RecipientTypeDetails.UserMailbox) { goto IL_91; } switch ((int)(recipientTypeDetails - RecipientTypeDetails.UserMailbox)) { case 0: case 1: case 2: goto IL_91; case 3: return(RecipientTypeDetails.RemoteSharedMailbox); } } if (recipientTypeDetails == RecipientTypeDetails.RoomMailbox) { return(RecipientTypeDetails.RemoteRoomMailbox); } } else { if (recipientTypeDetails == RecipientTypeDetails.EquipmentMailbox) { return(RecipientTypeDetails.RemoteEquipmentMailbox); } if (recipientTypeDetails == RecipientTypeDetails.TeamMailbox) { return(RecipientTypeDetails.RemoteTeamMailbox); } } IL_91: result = (RecipientTypeDetails)((ulong)int.MinValue); } else { result = RecipientTypeDetails.MailUser; } return(result); }
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; } }