Esempio n. 1
0
        public IAsyncResult BeginEwsCall(AsyncCallback callback, object state)
        {
            SearchMailboxesParameters searchMailboxesParameters = new SearchMailboxesParameters();

            searchMailboxesParameters.SearchQueries            = DiscoveryEwsClient.GetMailboxQueries(this.mailboxes, this.searchCriteria, this.pagingInfo);
            searchMailboxesParameters.ResultType               = DiscoveryEwsClient.GetSearchType(this.searchCriteria.SearchType);
            searchMailboxesParameters.SortBy                   = DiscoveryEwsClient.GetSortbyProperty(this.pagingInfo.SortBy);
            searchMailboxesParameters.SortOrder                = DiscoveryEwsClient.GetSortDirection(this.pagingInfo.SortBy);
            searchMailboxesParameters.PerformDeduplication     = this.pagingInfo.ExcludeDuplicates;
            searchMailboxesParameters.PageSize                 = this.pagingInfo.PageSize;
            searchMailboxesParameters.PageDirection            = DiscoveryEwsClient.GetPageDirection(this.pagingInfo.Direction);
            searchMailboxesParameters.PageItemReference        = ((this.pagingInfo.SortValue == null) ? null : this.pagingInfo.SortValue.ToString());
            searchMailboxesParameters.PreviewItemResponseShape = DiscoveryEwsClient.GetPreviewItemResponseShape(this.pagingInfo.BaseShape, this.pagingInfo.AdditionalProperties);
            if (this.searchCriteria.QueryCulture != null && !string.IsNullOrEmpty(this.searchCriteria.QueryCulture.Name))
            {
                searchMailboxesParameters.Language = this.searchCriteria.QueryCulture.Name;
            }
            return(this.service.BeginSearchMailboxes(callback, state, searchMailboxesParameters));
        }
Esempio n. 2
0
        internal static PreviewItemResponseShape GetPreviewItemResponseShape(PreviewItemBaseShape baseShape, List <ExtendedPropertyInfo> additionalProperties)
        {
            if (baseShape == PreviewItemBaseShape.Default && (additionalProperties == null || additionalProperties.Count == 0))
            {
                return(null);
            }
            PreviewItemResponseShape previewItemResponseShape = new PreviewItemResponseShape
            {
                BaseShape = DiscoveryEwsClient.GetBaseShape(baseShape)
            };
            int num = 0;

            if (additionalProperties != null)
            {
                previewItemResponseShape.AdditionalProperties = new ExtendedPropertyDefinition[additionalProperties.Count];
                num = additionalProperties.Count;
            }
            for (int i = 0; i < num; i++)
            {
                ExtendedPropertyDefinition extendedPropertyDefinition = DiscoveryEwsClient.ConvertExtendedPropertyInfoToExtendedPropertyDefinition(additionalProperties[i]);
                previewItemResponseShape.AdditionalProperties[i] = extendedPropertyDefinition;
            }
            return(previewItemResponseShape);
        }
Esempio n. 3
0
        public DiscoveryEwsClient(GroupId groupId, MailboxInfo[] mailboxes, SearchCriteria searchCriteria, PagingInfo pagingInfo, CallerInfo caller)
        {
            this.groupId        = groupId;
            this.mailboxes      = mailboxes;
            this.searchCriteria = searchCriteria;
            this.pagingInfo     = pagingInfo;
            this.callerInfo     = caller;
            CertificateValidationManager.RegisterCallback(base.GetType().FullName, new RemoteCertificateValidationCallback(CertificateValidation.CertificateErrorHandler));
            this.service     = new ExchangeService(4, DiscoveryEwsClient.GetTimeZoneInfoFromExTimeZone(this.pagingInfo.TimeZone));
            this.service.Url = this.groupId.Uri;
            this.service.HttpHeaders[CertificateValidationManager.ComponentIdHeaderName] = base.GetType().FullName;
            string text = string.Format("{0}&FOUT=true", caller.UserAgent);

            if (this.groupId.GroupType != GroupType.CrossPremise)
            {
                this.service.UserAgent = WellKnownUserAgent.GetEwsNegoAuthUserAgent(string.Format("{0}-{1}", DiscoveryEwsClient.CrossServerUserAgent, text));
            }
            else
            {
                this.service.UserAgent = text;
            }
            this.service.ClientRequestId = this.callerInfo.QueryCorrelationId.ToString("N");
            this.Authenticate();
        }