internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.CalendarOriginatorId))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.CalendarOriginatorId);
                if (obj is string)
                {
                    string text2 = (string)obj;
                    PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.CalendarOriginatorId);
                    if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified)
                    {
                        MailboxSession mailboxSession = context.Session as MailboxSession;
                        if (mailboxSession != null && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            string text3 = (string)originalPropertyInformation.OriginalPropertyValue;
                            int?   num   = CalendarOriginatorIdProperty.Compare(text2, text3);
                            if (num != null && num < 0 && !mailboxSession.Capabilities.CanSetCalendarAPIProperties && mailboxSession.LogonType != LogonType.Transport)
                            {
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, string>((long)this.GetHashCode(), "CalendarOriginatorIdConstraint::Validate. calendar originator value changed. Original = {0}, Current = {1}", text3, text2);
                                return(new StoreObjectValidationError(context, InternalSchema.CalendarOriginatorId, text2, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
        internal static string GetPreferredCalendarOriginatorId(string calendarOriginatorIdToCheck, string storedCalendarOriginatorId)
        {
            bool flag  = string.IsNullOrWhiteSpace(calendarOriginatorIdToCheck);
            bool flag2 = string.IsNullOrWhiteSpace(storedCalendarOriginatorId);

            if (flag && flag2)
            {
                return(null);
            }
            if (flag)
            {
                string[] array;
                if (!CalendarOriginatorIdProperty.TryParse(storedCalendarOriginatorId, out array))
                {
                    return(null);
                }
                return(storedCalendarOriginatorId);
            }
            else
            {
                if (flag2)
                {
                    return(calendarOriginatorIdToCheck);
                }
                int?num = CalendarOriginatorIdProperty.Compare(storedCalendarOriginatorId, calendarOriginatorIdToCheck);
                if (num != null && num >= 0)
                {
                    return(storedCalendarOriginatorId);
                }
                return(calendarOriginatorIdToCheck);
            }
        }
 internal static int?Compare(string originatorId1, string originatorId2)
 {
     if (string.Compare(originatorId1, originatorId2, StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new int?(0));
     }
     if (string.IsNullOrWhiteSpace(originatorId1) || string.IsNullOrWhiteSpace(originatorId2))
     {
         return(null);
     }
     string[] array;
     if (!CalendarOriginatorIdProperty.TryParse(originatorId1, out array))
     {
         return(null);
     }
     string[] array2;
     if (!CalendarOriginatorIdProperty.TryParse(originatorId2, out array2))
     {
         return(null);
     }
     if (string.Compare(array[CalendarOriginatorIdProperty.CalendarOriginatorIdGuidIndex], array2[CalendarOriginatorIdProperty.CalendarOriginatorIdGuidIndex], StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new int?(1));
     }
     if (string.Compare(array[CalendarOriginatorIdProperty.CalendarOriginatorIdLegDNIndex], array2[CalendarOriginatorIdProperty.CalendarOriginatorIdLegDNIndex], StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(new int?(1));
     }
     return(new int?(-1));
 }
 internal static bool TryCreate(MailboxSession session, out string calendarOriginatorId)
 {
     return(CalendarOriginatorIdProperty.TryCreate(session.MailboxGuid, session.MailboxOwnerLegacyDN, out calendarOriginatorId));
 }
Example #5
0
        public bool VerifyCalendarOriginatorId(MailboxSession itemStore, CalendarItemBase calendarItem, string internetMessageId, out string participantMatchFailure)
        {
            participantMatchFailure = null;
            if (calendarItem == null)
            {
                return(true);
            }
            if (!(this is MeetingRequest) && !(this is MeetingCancellation))
            {
                return(true);
            }
            string valueOrDefault  = base.GetValueOrDefault <string>(InternalSchema.CalendarOriginatorId);
            string valueOrDefault2 = calendarItem.GetValueOrDefault <string>(InternalSchema.CalendarOriginatorId);
            int?   num             = CalendarOriginatorIdProperty.Compare(valueOrDefault2, valueOrDefault);

            if (num != null)
            {
                if (num == 0)
                {
                    return(true);
                }
                if (num > 0)
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "Calendar originator Id on the meeting request - {0} partially matches the originator Id on the calendar item - {1}. InternetMessageId = {2}, Mailbox = {3}.", new object[]
                    {
                        valueOrDefault,
                        valueOrDefault2,
                        internetMessageId,
                        itemStore.MailboxOwnerLegacyDN
                    });
                    return(true);
                }
                return(false);
            }
            else
            {
                ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "Calendar originator Id on the meeting request - {0} does not match the originator Id on the calendar item - {1}. InternetMessageId = {2}, Mailbox = {3}. Verifying From.", new object[]
                {
                    valueOrDefault,
                    valueOrDefault2,
                    internetMessageId,
                    itemStore.MailboxOwnerLegacyDN
                });
                Participant organizer = calendarItem.Organizer;
                Participant from      = base.From;
                if (!(organizer != null))
                {
                    participantMatchFailure = "Organizer on the calendar item is not set.";
                    return(true);
                }
                if (Participant.HasSameEmail(organizer, from))
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "From on the meeting request - {0} matches Organizer on the calendar item - {1}. InternetMessageId = {2}, Mailbox = {3}.", new object[]
                    {
                        from,
                        organizer,
                        internetMessageId,
                        itemStore.MailboxOwnerLegacyDN
                    });
                    return(true);
                }
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, Participant.BatchBuilder.GetADSessionSettings(itemStore), 870, "VerifyCalendarOriginatorId", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Calendar\\MeetingMessage.cs");
                ADRecipient       adrecipient = null;
                if (from.TryGetADRecipient(tenantOrRootOrgRecipientSession, out adrecipient) && adrecipient != null)
                {
                    if (Participant.HasProxyAddress(adrecipient, organizer))
                    {
                        ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "HasProxyAddress succeeded - From: {0} on calendar item matches From on the meeting request - {1}. InternetMessageId = {2}, Mailbox = {3}.", new object[]
                        {
                            organizer,
                            from,
                            internetMessageId,
                            itemStore.MailboxOwnerLegacyDN
                        });
                        return(true);
                    }
                    participantMatchFailure = string.Format("Particpant match failure, Failed to match proxyAddresses. Calendar.From={0}, mtg.From={1}", organizer, from);
                }
                else
                {
                    participantMatchFailure = string.Format("Particpant match failure, Failed to get the AD Recipient. Calendar.From={0}, mtg.From={1}", organizer, from);
                }
                return(true);
            }
        }