Exemple #1
0
        private static User CreateUserFromMailboxInfo(MailboxInfo mailbox)
        {
            SmtpAddress primarySmtpAddress;

            if (mailbox.IsArchive)
            {
                string text = (mailbox.ArchiveDomain != null) ? mailbox.ArchiveDomain.Domain : null;
                if (text == null)
                {
                    text = mailbox.PrimarySmtpAddress.Domain;
                }
                primarySmtpAddress = new SmtpAddress(SmtpProxyAddress.EncapsulateExchangeGuid(text, mailbox.ArchiveGuid));
            }
            else if (mailbox.ExternalEmailAddress != null)
            {
                primarySmtpAddress = new SmtpAddress(mailbox.ExternalEmailAddress.AddressString);
            }
            else
            {
                primarySmtpAddress = mailbox.PrimarySmtpAddress;
            }
            return(new User
            {
                Mailbox = primarySmtpAddress.ToString()
            });
        }
Exemple #2
0
        private GroupId GetGroupId(MailboxInfo mailbox, UserResponse userResponse)
        {
            if (userResponse == null)
            {
                return(new GroupId(new MultiMailboxSearchException(Strings.descSoapAutoDiscoverInvalidResponseError(this.autodiscoveryEndpoint.ToString()))));
            }
            GroupId result = null;

            if (userResponse.ErrorCodeSpecified && this.HasResponseErrorCode(mailbox, userResponse, out result))
            {
                return(result);
            }
            if (this.HasSettingErrorInResponse(mailbox, userResponse, out result))
            {
                return(result);
            }
            string stringSettingFromResponse  = this.GetStringSettingFromResponse(userResponse, mailbox, UserSettingAutodiscovery.ExternalEwsVersion);
            string stringSettingFromResponse2 = this.GetStringSettingFromResponse(userResponse, mailbox, UserSettingAutodiscovery.ExternalEwsUrl);

            if (stringSettingFromResponse2 == null)
            {
                Factory.Current.AutodiscoverTracer.TraceError <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. Request '{1}' for user {2} got no URL value.", this.callerInfo.QueryCorrelationId, this.autodiscoveryEndpoint.ToString(), mailbox.ToString());
                return(new GroupId(new MultiMailboxSearchException(Strings.descSoapAutoDiscoverRequestUserSettingInvalidError(this.autodiscoveryEndpoint.ToString(), UserSettingAutodiscovery.ExternalEwsUrl))));
            }
            return(new GroupId(GroupType.CrossPremise, new Uri(stringSettingFromResponse2), this.ParseVersionString(stringSettingFromResponse), null)
            {
                Domain = mailbox.GetDomain()
            });
        }
        private List <Pair <MailboxInfo, Exception> > ConvertToPreviewErrors(FailedSearchMailbox[] failedMailboxes)
        {
            List <Pair <MailboxInfo, Exception> > list = new List <Pair <MailboxInfo, Exception> >(failedMailboxes.Length);
            List <MailboxInfo> list2 = new List <MailboxInfo>(failedMailboxes.Length);

            for (int i = 0; i < failedMailboxes.Length; i++)
            {
                FailedSearchMailbox failedSearchMailbox = failedMailboxes[i];
                if (failedSearchMailbox == null)
                {
                    Factory.Current.GeneralTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Null failed mailbox encountered in search result from {1}", base.ExecutingUser.QueryCorrelationId, this.Uri.AbsoluteUri);
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidFailedMailboxesResultWebServiceResponse(this.Uri.AbsoluteUri));
                }
                MailboxInfo info = this.FindMailboxInfoByAnyIdentifier(failedSearchMailbox, failedSearchMailbox.Mailbox, null, new bool?(failedSearchMailbox.IsArchive));
                if (info == null || string.IsNullOrEmpty(failedSearchMailbox.ErrorMessage))
                {
                    Factory.Current.GeneralTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Invalid mailbox encountered in search result from {1}", base.ExecutingUser.QueryCorrelationId, this.Uri.AbsoluteUri);
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidFailedMailboxesResultWebServiceResponse(this.Uri.AbsoluteUri));
                }
                if ((from x in list2
                     where string.Equals(x.LegacyExchangeDN, info.LegacyExchangeDN, StringComparison.OrdinalIgnoreCase) && x.Type == info.Type
                     select x).FirstOrDefault <MailboxInfo>() != null)
                {
                    Factory.Current.GeneralTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Duplicate failed mailbox encountered in search result from {1}", base.ExecutingUser.QueryCorrelationId, this.Uri.AbsoluteUri);
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidFailedMailboxesResultDuplicateEntries(this.Uri.AbsoluteUri));
                }
                list2.Add(info);
                list.Add(new Pair <MailboxInfo, Exception>(info, new Exception(failedSearchMailbox.ErrorMessage)));
            }
            return(list);
        }
        private MailboxInfo FindMailboxInfoByGuid(string legacyDn, string mailboxGuidString)
        {
            if (string.IsNullOrEmpty(mailboxGuidString))
            {
                return(this.FindMailboxInfo(legacyDn, null));
            }
            Guid guid;

            if (!Guid.TryParse(mailboxGuidString, out guid) || guid.Equals(Guid.Empty))
            {
                return(this.FindMailboxInfo(legacyDn, null));
            }
            MailboxInfo mailboxInfo = this.FindMailboxInfo(legacyDn, new bool?(false));

            if (mailboxInfo != null && guid.Equals(mailboxInfo.MailboxGuid))
            {
                return(mailboxInfo);
            }
            MailboxInfo mailboxInfo2 = this.FindMailboxInfo(legacyDn, new bool?(true));

            if (mailboxInfo2 != null && guid.Equals(mailboxInfo2.MailboxGuid))
            {
                return(mailboxInfo2);
            }
            if (mailboxInfo != null && Guid.Empty.Equals(mailboxInfo.MailboxGuid))
            {
                return(mailboxInfo);
            }
            return(null);
        }
 public SearchMailboxResult(MailboxInfo mailbox, Exception error)
 {
     Util.ThrowOnNull(mailbox, "mailbox");
     Util.ThrowOnNull(error, "error");
     this.mailbox          = mailbox;
     this.success          = false;
     this.resultType       = SearchType.Preview;
     this.totalResultCount = 0UL;
     this.exception        = error;
 }
Exemple #6
0
        public static Uri GetOwaMailboxItemLink(Action errorHandler, MailboxInfo mailboxInfo, bool supportsIntegratedAuth)
        {
            Uri uri = LinkUtils.GetOwaBaseLink(errorHandler, mailboxInfo, supportsIntegratedAuth);

            if (uri != null)
            {
                uri = LinkUtils.AppendQueryString(uri, LinkUtils.itemLinkParameters);
            }
            return(uri);
        }
 internal void MergeMailboxResult(MailboxInfo info, Exception ex)
 {
     if (base.SearchCriteria.SearchType == SearchType.Preview || base.SearchCriteria.SearchType == SearchType.NonIndexedItemPreview || base.SearchCriteria.SearchType == SearchType.NonIndexedItemStatistics)
     {
         base.ResultAggregator.MergeSearchResult(new SearchMailboxResult(info, ex));
     }
     if (base.SearchCriteria.SearchType == SearchType.Statistics)
     {
         base.ResultAggregator.MergeSearchResult(new SearchMailboxResult(info, new KeywordHit(base.SearchCriteria.QueryString, info, ex)));
     }
 }
Exemple #8
0
        private void AddMailboxToGroup(MailboxInfo mailbox, GroupId groupId)
        {
            List <MailboxInfo> list = null;

            if (!this.mailboxGroups.TryGetValue(groupId, out list))
            {
                list = new List <MailboxInfo>(1);
                this.mailboxGroups.Add(groupId, list);
            }
            list.Add(mailbox);
        }
Exemple #9
0
 public KeywordHit(string phrase, MailboxInfo mailbox, Exception exception)
 {
     Util.ThrowOnNull(phrase, "phrase");
     Util.ThrowOnNull(mailbox, "mailbox");
     Util.ThrowOnNull(exception, "exception");
     if (string.IsNullOrEmpty(phrase))
     {
         throw new ArgumentException("Phrase cannot be empty");
     }
     this.phrase = phrase;
     this.errors.Add(new Pair <MailboxInfo, Exception>(mailbox, exception));
 }
Exemple #10
0
        private void AddMailboxToGroup(MailboxInfo mailbox, BackEndServer server)
        {
            Uri backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(server);

            if (string.Equals(LocalServerCache.LocalServerFqdn, server.Fqdn, StringComparison.OrdinalIgnoreCase))
            {
                Factory.Current.MailboxGroupGeneratorTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Mailbox {1} is a local mailbox", this.callerInfo.QueryCorrelationId, mailbox.ToString());
                this.AddMailboxToGroup(mailbox, new GroupId(GroupType.Local, backEndWebServicesUrl, LocalServerCache.LocalServer.VersionNumber, mailbox.GetDomain()));
                return;
            }
            Factory.Current.MailboxGroupGeneratorTracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. Mailbox {1} is mapped to service {2}", this.callerInfo.QueryCorrelationId, mailbox.ToString(), backEndWebServicesUrl.ToString());
            this.AddMailboxToGroup(mailbox, new GroupId(GroupType.CrossServer, backEndWebServicesUrl, server.Version, mailbox.GetDomain()));
        }
 public SearchMailboxResult(MailboxInfo mailbox, IKeywordHit keyword)
 {
     Util.ThrowOnNull(mailbox, "mailbox");
     Util.ThrowOnNull(keyword, "keyword");
     this.mailbox    = mailbox;
     this.resultType = SearchType.Statistics;
     this.keywordHit = keyword;
     this.success    = true;
     if (keyword.Errors.Count != 0)
     {
         this.success = false;
     }
 }
        public SearchMailboxResult(MailboxInfo mailbox, SortedResultPage result, ulong totalResultCount)
        {
            Util.ThrowOnNull(mailbox, "mailbox");
            Util.ThrowOnNull(result, "result");
            int resultCount = result.ResultCount;

            this.resultType       = SearchType.Preview;
            this.mailbox          = mailbox;
            this.result           = result;
            this.totalResultCount = totalResultCount;
            this.mailboxStats     = new List <MailboxStatistics>
            {
                new MailboxStatistics(mailbox, this.totalResultCount, this.TotalResultSize)
            };
            this.success = true;
        }
Exemple #13
0
        private bool HasResponseErrorCode(MailboxInfo mailbox, UserResponse userResponse, out GroupId groupId)
        {
            groupId = null;
            if (!userResponse.ErrorCodeSpecified)
            {
                return(false);
            }
            switch (userResponse.ErrorCode)
            {
            case ErrorCode.NoError:
                return(false);

            case ErrorCode.RedirectAddress:
                Factory.Current.AutodiscoverTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' got address redirect response for user {3} to {4}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    TraceContext.Get(),
                    this,
                    mailbox.ToString(),
                    userResponse.RedirectTarget
                });
                groupId = new GroupId(new MultiMailboxSearchException(new LocalizedString("Redirect address for autodiscovery is not supported")));
                return(true);

            case ErrorCode.RedirectUrl:
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' got URL redirect response for user {3} but the redirect value is not valid: {4}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    TraceContext.Get(),
                    this,
                    mailbox.ToString(),
                    userResponse.RedirectTarget
                });
                groupId = new GroupId(new MultiMailboxSearchException(new LocalizedString("Redirect urls for autodiscovery is not supported")));
                return(true);

            default:
                groupId = new GroupId(new MultiMailboxSearchException(Strings.descSoapAutoDiscoverRequestUserSettingError(this.autodiscoveryEndpoint.ToString(), UserSettingAutodiscovery.ExternalEwsUrl, userResponse.ErrorCode.ToString())));
                return(true);
            }
        }
Exemple #14
0
        private bool HasSettingErrorInResponse(MailboxInfo mailbox, UserResponse userResponse, out GroupId groupId)
        {
            groupId = null;
            UserSettingError settingErrorFromResponse = this.GetSettingErrorFromResponse(userResponse, UserSettingAutodiscovery.ExternalEwsUrl);

            if (settingErrorFromResponse != null)
            {
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. Request '{1}' got error response for user {2}. Error: {3}:{4}:{5}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    this,
                    mailbox.ToString(),
                    settingErrorFromResponse.SettingName,
                    settingErrorFromResponse.ErrorCode,
                    settingErrorFromResponse.ErrorMessage
                });
                groupId = new GroupId(new MultiMailboxSearchException(Strings.descSoapAutoDiscoverRequestUserSettingError(this.autodiscoveryEndpoint.ToString(), settingErrorFromResponse.SettingName, settingErrorFromResponse.ErrorMessage)));
                return(true);
            }
            return(false);
        }
        private List <MailboxStatistics> ConvertMailboxStatistics(MailboxStatisticsItem[] ewsMailboxStatistics, bool emptyResults)
        {
            if (!emptyResults && (ewsMailboxStatistics == null || ewsMailboxStatistics.Length == 0))
            {
                throw new WebServiceProxyInvalidResponseException(Strings.EmptyMailboxStatsServerResponse(this.Uri.AbsoluteUri));
            }
            List <MailboxStatistics> list = null;

            if (ewsMailboxStatistics != null)
            {
                list = new List <MailboxStatistics>(ewsMailboxStatistics.Length);
                foreach (MailboxStatisticsItem mailboxStatisticsItem in ewsMailboxStatistics)
                {
                    MailboxInfo mailboxInfo = this.FindMailboxInfoByAnyIdentifier(mailboxStatisticsItem, mailboxStatisticsItem.MailboxId, null, null);
                    if (mailboxInfo == null)
                    {
                        Factory.Current.GeneralTracer.TraceError <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Invalid mailbox encountered in statistics result from {1}", base.ExecutingUser.QueryCorrelationId, this.Uri.AbsoluteUri);
                        throw new WebServiceProxyInvalidResponseException(Strings.InvalidMailboxInMailboxStatistics(this.Uri.AbsoluteUri));
                    }
                    list.Add(new MailboxStatistics(mailboxInfo, (ulong)mailboxStatisticsItem.ItemCount, new ByteQuantifiedSize(mailboxStatisticsItem.Size)));
                }
            }
            return(list);
        }
Exemple #16
0
        private static PreviewItem[] InternalCreateSearchPreviewItems(MailboxInfo mailboxInfo, object[][] rows, PagingInfo pagingInfo, StoreSession mailboxSession, List <KeyValuePair <int, long> > messageIdPairs, bool usingSearchFolders)
        {
            if (!usingSearchFolders)
            {
                Util.ThrowOnNull(messageIdPairs, "messageIdPairs");
            }
            if (rows.Length == 0 || rows[0].Length != pagingInfo.DataColumns.Count)
            {
                throw new ArgumentException("Invalid result rows");
            }
            List <PreviewItem> list = new List <PreviewItem>(rows.Length);
            StoreId            sentItemsFolderId = null;

            if (!mailboxSession.IsPublicFolderSession)
            {
                sentItemsFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.SentItems);
            }
            Uri owaMailboxItemLink = LinkUtils.GetOwaMailboxItemLink(delegate
            {
            }, mailboxInfo, true);

            for (int i = 0; i < rows.Length; i++)
            {
                object[] array = rows[i];
                Dictionary <PropertyDefinition, object> properties = new Dictionary <PropertyDefinition, object>(4);
                int num = 0;
                foreach (PropertyDefinition key in pagingInfo.DataColumns)
                {
                    properties.Add(key, array[num]);
                    num++;
                }
                ReferenceItem sortValue = null;
                if (!usingSearchFolders)
                {
                    sortValue = new ReferenceItem(pagingInfo.SortBy, properties[pagingInfo.SortColumn], messageIdPairs.Find((KeyValuePair <int, long> x) => x.Key == (int)properties[ItemSchema.DocumentId]).Value);
                }
                else
                {
                    sortValue = new ReferenceItem(pagingInfo.SortBy, properties[pagingInfo.SortColumn], (long)mailboxSession.MailboxGuid.GetHashCode() << 32 | (long)((ulong)((int)properties[ItemSchema.DocumentId])));
                }
                List <PropertyDefinition> list2 = null;
                if (pagingInfo.AdditionalProperties != null && pagingInfo.AdditionalProperties.Count > 0)
                {
                    list2 = new List <PropertyDefinition>(pagingInfo.AdditionalProperties.Count);
                    foreach (ExtendedPropertyInfo extendedPropertyInfo in pagingInfo.AdditionalProperties)
                    {
                        list2.Add(extendedPropertyInfo.XsoPropertyDefinition);
                    }
                }
                PreviewItem item = new PreviewItem(properties, mailboxInfo.MailboxGuid, owaMailboxItemLink, sortValue, Util.CalculateUniqueItemHash(mailboxSession, array, pagingInfo, sentItemsFolderId), list2)
                {
                    MailboxInfo = mailboxInfo
                };
                list.Add(item);
            }
            PreviewItem[] array2 = list.ToArray();
            if (pagingInfo.ExcludeDuplicates)
            {
                array2 = Util.ExcludeDuplicateItems(array2);
            }
            return(array2);
        }
Exemple #17
0
 public static Uri GetOwaBaseLink(Action errorHandler, MailboxInfo mailboxInfo, bool supportsIntegratedAuth)
 {
     Util.ThrowOnNull(mailboxInfo, "mailboxInfo");
     Util.ThrowOnNull(mailboxInfo.ExchangePrincipal, "mailboxInfo.ExchangePrincipal");
     return(LinkUtils.GetOwaBaseLink(errorHandler, mailboxInfo.ExchangePrincipal, supportsIntegratedAuth));
 }
        private SortedResultPage ConvertToPreviewItems(SearchPreviewItem[] ewsPreviewItems)
        {
            if (ewsPreviewItems == null)
            {
                return(new SortedResultPage(new PreviewItem[0], base.PagingInfo));
            }
            List <PreviewItem> list = new List <PreviewItem>(ewsPreviewItems.Length);

            foreach (SearchPreviewItem searchPreviewItem in ewsPreviewItems)
            {
                try
                {
                    MailboxId   mailboxId;
                    VersionedId value       = WebServiceMailboxSearchGroup.EwsIdToVersionedId(searchPreviewItem.Id.UniqueId, searchPreviewItem.Id.ChangeKey, out mailboxId);
                    MailboxInfo mailboxInfo = this.FindMailboxInfoByAnyIdentifier(searchPreviewItem, searchPreviewItem.Mailbox.MailboxId, mailboxId.MailboxGuid, null);
                    if (mailboxInfo == null)
                    {
                        throw new WebServiceProxyInvalidResponseException(Strings.InvalidUnknownMailboxInPreviewResult(this.Uri.AbsoluteUri, searchPreviewItem.Mailbox.MailboxId, mailboxId.MailboxGuid));
                    }
                    Dictionary <PropertyDefinition, object> dictionary = new Dictionary <PropertyDefinition, object>();
                    dictionary.Add(ItemSchema.Id, value);
                    dictionary.Add(StoreObjectSchema.ParentItemId, StoreId.EwsIdToStoreObjectId(searchPreviewItem.ParentId.UniqueId));
                    dictionary.Add(StoreObjectSchema.ItemClass, searchPreviewItem.ItemClass);
                    dictionary.Add(MessageItemSchema.SenderDisplayName, searchPreviewItem.Sender);
                    dictionary.Add(ItemSchema.DisplayTo, this.GetSemicolonSeparated(searchPreviewItem.ToRecipients));
                    dictionary.Add(ItemSchema.DisplayCc, this.GetSemicolonSeparated(searchPreviewItem.CcRecipients));
                    dictionary.Add(ItemSchema.DisplayBcc, this.GetSemicolonSeparated(searchPreviewItem.BccRecipients));
                    dictionary.Add(StoreObjectSchema.CreationTime, WebServiceMailboxSearchGroup.CreateExDateTime(base.PagingInfo.TimeZone, searchPreviewItem.CreatedTime, this));
                    dictionary.Add(ItemSchema.ReceivedTime, WebServiceMailboxSearchGroup.CreateExDateTime(base.PagingInfo.TimeZone, searchPreviewItem.ReceivedTime, this));
                    dictionary.Add(ItemSchema.SentTime, WebServiceMailboxSearchGroup.CreateExDateTime(base.PagingInfo.TimeZone, searchPreviewItem.SentTime, this));
                    dictionary.Add(ItemSchema.Subject, searchPreviewItem.Subject);
                    dictionary.Add(ItemSchema.Size, (int)searchPreviewItem.Size);
                    dictionary.Add(ItemSchema.Importance, searchPreviewItem.Importance.ToString());
                    dictionary.Add(MessageItemSchema.IsRead, searchPreviewItem.Read);
                    dictionary.Add(ItemSchema.HasAttachment, searchPreviewItem.HasAttachment);
                    if (searchPreviewItem.OwaLink == null)
                    {
                        Factory.Current.GeneralTracer.TraceError <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. Null OWA URI in item with Id {1} in mailbox {2}", base.ExecutingUser.QueryCorrelationId, searchPreviewItem.Id.UniqueId, searchPreviewItem.Mailbox.PrimarySmtpAddress);
                        throw new WebServiceProxyInvalidResponseException(Strings.InvalidOwaUrlInPreviewResult(string.Format("EDiscoveryError:E002::Mailbox:{0}::Item:{1}::", searchPreviewItem.Mailbox.PrimarySmtpAddress, searchPreviewItem.Subject), this.Uri.AbsoluteUri));
                    }
                    PreviewItem item = new PreviewItem(dictionary, mailboxInfo.MailboxGuid.Equals(Guid.Empty) ? Guid.Parse(mailboxId.MailboxGuid) : mailboxInfo.MailboxGuid, new Uri(searchPreviewItem.OwaLink), this.GetReferenceItem(searchPreviewItem.SortValue), this.GetUniqueItemHash(searchPreviewItem.UniqueHash))
                    {
                        MailboxInfo = mailboxInfo
                    };
                    list.Add(item);
                }
                catch (InvalidIdMalformedException ex)
                {
                    Factory.Current.GeneralTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. Error processing item with Id {1} in mailbox {2}: {3}", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        searchPreviewItem.Id.UniqueId,
                        searchPreviewItem.Mailbox.PrimarySmtpAddress,
                        ex.ToString()
                    });
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidIdInPreviewResult(this.Uri.AbsoluteUri), ex);
                }
                catch (UriFormatException ex2)
                {
                    Factory.Current.GeneralTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. Invalid OWA URI in item with Id {1} in mailbox {2}: {3}", new object[]
                    {
                        base.ExecutingUser.QueryCorrelationId,
                        searchPreviewItem.Id.UniqueId,
                        searchPreviewItem.Mailbox.PrimarySmtpAddress,
                        ex2.ToString()
                    });
                    throw new WebServiceProxyInvalidResponseException(Strings.InvalidOwaUrlInPreviewResult(string.Format("EDiscoveryError:E002::Mailbox:{0}::Item:{1}::", searchPreviewItem.Mailbox.PrimarySmtpAddress, searchPreviewItem.Subject), this.Uri.AbsoluteUri), ex2);
                }
            }
            return(new SortedResultPage(list.ToArray(), base.PagingInfo));
        }
Exemple #19
0
 public SearchFolderQueryFailedException(MailboxInfo mailbox) : base(mailbox.IsPrimary ? Strings.PrimarySearchPopulationFailed(mailbox.DisplayName, mailbox.MailboxGuid.ToString()) : Strings.ArchiveSearchPopulationFailed(mailbox.DisplayName, mailbox.MailboxGuid.ToString()))
 {
 }
        protected void PerformMailboxDiscovery(ADRawEntry adRawEntry, MailboxType mailboxType, out GroupId groupId, out MailboxInfo mailboxInfo)
        {
            List <MailboxInfo> list = new List <MailboxInfo>(1);

            list.Add(new MailboxInfo(adRawEntry, mailboxType));
            IEwsEndpointDiscovery ewsEndpointDiscovery = Factory.Current.GetEwsEndpointDiscovery(list, this.orgId, this.callerInfo);
            long num  = 0L;
            long num2 = 0L;
            Dictionary <GroupId, List <MailboxInfo> >   source       = ewsEndpointDiscovery.FindEwsEndpoints(out num, out num2);
            KeyValuePair <GroupId, List <MailboxInfo> > keyValuePair = source.First <KeyValuePair <GroupId, List <MailboxInfo> > >();

            groupId     = keyValuePair.Key;
            mailboxInfo = keyValuePair.Value[0];
        }
Exemple #21
0
 public SearchMailboxTaskCancelledException(MailboxInfo mailbox) : base(mailbox.IsPrimary ? Strings.SearchTaskCancelledPrimary(mailbox.DisplayName, mailbox.MailboxGuid.ToString()) : Strings.SearchTaskCancelledArchive(mailbox.DisplayName, mailbox.MailboxGuid.ToString()))
 {
 }
Exemple #22
0
 internal static PreviewItem[] CreateSearchPreviewItems(MailboxInfo mailboxInfo, object[][] rows, StoreSession mailboxSession, PagingInfo pagingInfo)
 {
     Util.ThrowOnNull(rows, "rows");
     return(Util.InternalCreateSearchPreviewItems(mailboxInfo, rows, pagingInfo, mailboxSession, null, true));
 }
Exemple #23
0
 public QueryFilter GetPagingFilter(MailboxInfo mailbox)
 {
     if (this.referenceItem == null || this.referenceItem.SortColumnValue == null)
     {
         return(null);
     }
     if (this.direction == PageDirection.Next)
     {
         if (this.sort.SortOrder == SortOrder.Ascending)
         {
             if (this.referenceItem.MailboxIdHash < mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             if (this.referenceItem.MailboxIdHash > mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.GreaterThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             ComparisonFilter comparisonFilter  = new ComparisonFilter(ComparisonOperator.GreaterThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter2 = new ComparisonFilter(ComparisonOperator.Equal, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter3 = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.DocumentId, this.referenceItem.DocId);
             AndFilter        andFilter         = new AndFilter(new QueryFilter[]
             {
                 comparisonFilter2,
                 comparisonFilter3
             });
             return(new OrFilter(new QueryFilter[]
             {
                 comparisonFilter,
                 andFilter
             }));
         }
         else
         {
             if (this.referenceItem.MailboxIdHash < mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.LessThanOrEqual, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             if (this.referenceItem.MailboxIdHash > mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.LessThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             ComparisonFilter comparisonFilter4 = new ComparisonFilter(ComparisonOperator.LessThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter5 = new ComparisonFilter(ComparisonOperator.Equal, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter6 = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.DocumentId, this.referenceItem.DocId);
             AndFilter        andFilter2        = new AndFilter(new QueryFilter[]
             {
                 comparisonFilter5,
                 comparisonFilter6
             });
             return(new OrFilter(new QueryFilter[]
             {
                 comparisonFilter4,
                 andFilter2
             }));
         }
     }
     else
     {
         if (this.direction != PageDirection.Previous)
         {
             return(null);
         }
         if (this.sort.SortOrder == SortOrder.Ascending)
         {
             if (this.referenceItem.MailboxIdHash < mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.LessThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             if (this.referenceItem.MailboxIdHash > mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.LessThanOrEqual, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             ComparisonFilter comparisonFilter7 = new ComparisonFilter(ComparisonOperator.LessThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter8 = new ComparisonFilter(ComparisonOperator.Equal, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter9 = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.DocumentId, this.referenceItem.DocId);
             AndFilter        andFilter3        = new AndFilter(new QueryFilter[]
             {
                 comparisonFilter8,
                 comparisonFilter9
             });
             return(new OrFilter(new QueryFilter[]
             {
                 comparisonFilter7,
                 andFilter3
             }));
         }
         else
         {
             if (this.referenceItem.MailboxIdHash < mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.GreaterThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             if (this.referenceItem.MailboxIdHash > mailbox.MailboxGuid.GetHashCode())
             {
                 return(new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue));
             }
             ComparisonFilter comparisonFilter10 = new ComparisonFilter(ComparisonOperator.GreaterThan, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter11 = new ComparisonFilter(ComparisonOperator.Equal, this.sort.ColumnDefinition, this.referenceItem.SortColumnValue);
             ComparisonFilter comparisonFilter12 = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.DocumentId, this.referenceItem.DocId);
             AndFilter        andFilter4         = new AndFilter(new QueryFilter[]
             {
                 comparisonFilter11,
                 comparisonFilter12
             });
             return(new OrFilter(new QueryFilter[]
             {
                 comparisonFilter10,
                 andFilter4
             }));
         }
     }
 }
Exemple #24
0
 private static bool ValidateCrossPremiseDomain(MailboxInfo mailbox, string domain)
 {
     return(string.Equals(domain, mailbox.GetDomain(), StringComparison.OrdinalIgnoreCase));
 }
Exemple #25
0
 public SearchMailboxTaskTimeoutException(MailboxInfo mailbox) : base(mailbox.IsPrimary ? Strings.SearchTaskTimeoutPrimary(mailbox.DisplayName, mailbox.MailboxGuid.ToString()) : Strings.SearchTaskTimeoutArchive(mailbox.DisplayName, mailbox.MailboxGuid.ToString()))
 {
 }
 public MailboxStatistics(MailboxInfo mailboxInfo, ulong count, ByteQuantifiedSize size)
 {
     this.mailboxInfo = mailboxInfo;
     this.count       = count;
     this.size        = size;
 }
Exemple #27
0
 public SearchUserNotFoundException(MailboxInfo info) : base(Strings.SearchUserNotFound(info.DisplayName))
 {
 }
Exemple #28
0
        private string GetStringSettingFromResponse(UserResponse userResponse, MailboxInfo mailbox, string settingName)
        {
            if (userResponse.UserSettings == null)
            {
                return(null);
            }
            UserSetting userSetting = null;

            foreach (UserSetting userSetting2 in userResponse.UserSettings)
            {
                if (StringComparer.InvariantCulture.Equals(userSetting2.Name, settingName))
                {
                    userSetting = userSetting2;
                    break;
                }
            }
            if (userSetting == null)
            {
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' for user {3} got response without setting {4}.", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    TraceContext.Get(),
                    this,
                    mailbox.ToString(),
                    settingName
                });
                return(null);
            }
            StringSetting stringSetting = userSetting as StringSetting;

            if (stringSetting == null)
            {
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' for user {3} got response for setting {4} of unexpected type: {5}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    TraceContext.Get(),
                    this,
                    mailbox.ToString(),
                    settingName,
                    userSetting.GetType().Name
                });
                return(null);
            }
            if (string.IsNullOrEmpty(stringSetting.Value))
            {
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' for user {3} got response with empty value for setting {4}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    TraceContext.Get(),
                    this,
                    mailbox.ToString(),
                    settingName
                });
                return(null);
            }
            Factory.Current.AutodiscoverTracer.TraceDebug((long)this.GetHashCode(), "Correlation Id:{0}. {1}: Request '{2}' for user {3} got response for setting {4} with value: {5}", new object[]
            {
                this.callerInfo.QueryCorrelationId,
                TraceContext.Get(),
                this,
                mailbox.ToString(),
                settingName,
                stringSetting.Value
            });
            return(stringSetting.Value);
        }
Exemple #29
0
 public SearchServerFailedException(MailboxInfo info, int responseCode, string exceptionMessage) : base(Strings.SearchServerFailed(info.DisplayName, responseCode, exceptionMessage))
 {
 }
Exemple #30
0
 internal static PreviewItem[] CreateSearchPreviewItems(MailboxInfo mailboxInfo, object[][] rows, List <KeyValuePair <int, long> > messageIdPairs, StoreSession mailboxSession, PagingInfo pagingInfo)
 {
     Util.ThrowOnNull(rows, "rows");
     return(Util.InternalCreateSearchPreviewItems(mailboxInfo, rows, pagingInfo, mailboxSession, messageIdPairs, false));
 }