Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS error gettingEvents

$
0
0

Im having an issue with Office 365 EWS (its only Office 365, Exchange 2010 and 2013 work fine).  I can create my pull subscription without error but when I go to use it by calling

getEvents()


I receivean error:

ErrorNoRespondingCASInDestinationSite

The following error occured while retrieving events for exchange resource: <room address> - Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.

Here is some code snippets

Using autodiscover and setting up credentials

this.exchangeService.Credentials = new NetworkCredential(this.Username, this.Password);
                    try {
                        this.exchangeService.AutodiscoverUrl(this.Username, RedirectionCallback);
                    }
                    catch(Exception ex)
                    {
                        Logger.WriteToEventLog(EventLogEntryType.Warning, 104, "ExchangeDataAccess, AutodiscoverURL error: " + ex.Message);
                    }

                    if (exchangeService.Url == null)
                    {
                        this.ExchangeServerURL = GetOffice365EWSUrl(this.Username);
                        this.exchangeService.Url = new Uri(this.ExchangeServerURL);
                        this.exchangeService.CookieContainer = new CookieContainer();
                    }


Afterwhich we Login and find our exchange user that we will perform all operations under

ServicePointManager.ServerCertificateValidationCallback = (sender1, certificate, chain, errors) => true;

                string username = this.Username;
                if (this.authenticateContext.GetExchangeServerVersion().Contains("365"))
                {
                    username = this.Username.Remove(this.Username.IndexOf("@"));
                }

                NameResolutionCollection resolveNameResult = this.exchangeService.ResolveName(username, ResolveNameSearchLocation.ContactsThenDirectory, true);

                if (resolveNameResult.Count() > 0)
                {
                    roomEmailAddress = resolveNameResult[0].Mailbox.Address;
                    if (!string.IsNullOrEmpty(roomEmailAddress))
                    {
                        this.ExchangeUserEmailAddress = roomEmailAddress;
                        logMsg.AppendLine("Logged into Exchange with " + roomEmailAddress + " successfully, RetrieveRoomsList is next");
                    }
                }


We then get a SubscribeResponse and save it to a list

                    subscribeResponse = this.exchangeDataAccess.ExchangeSubscribe(syncPoint.ThirdPartyId, syncPoint.Watermark, true);


We pass the above object into a wrapper method to get all Events from the EWS

            Dictionary<PullSubscription, IEnumerable<ItemEvent>> mailboxEvents = null;

            GetEventsResults eventsResults = subscription.GetEvents();

            if (eventsResults == null || eventsResults.ItemEvents.Count() == 0) {
                return mailboxEvents;
            }

            mailboxEvents = new Dictionary<PullSubscription, IEnumerable<ItemEvent>>();
            mailboxEvents.Add(subscription, eventsResults.ItemEvents);
            return mailboxEvents;

The line that calls subscription.GetEvents() is where the exception indicated at the top is returned.  

There is another layer of complexity added on because our Exchange user has a domain name of @FOOlab.onmicrosoft.com where as all of the rooms being managed have a domain name of @LAB.FOO.COM

According to the customer this is ADFS authentication, however I really don't know much about it.

I can say however that this code base did work (got events) and then something seemed to change and the error started popping up.  Originally I thought the customer changed something but we have tested this against another Office 365 (without ADFS) and saw the same error, so now I don't know what to think.   



Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>