This is driving me bonkers. I have been using the following c# code to pull messages from an on-prem Exchange mailbox, using Exchange Web Services:
es = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
{
Credentials = new WebCredentials(ConfigurationManager.AppSettings["User"].ToString(),
ConfigurationManager.AppSettings["Password"].ToString(),
ConfigurationManager.AppSettings["Domain"].ToString())
};
//es.TraceEnabled = true;
es.AutodiscoverUrl(ConfigurationManager.AppSettings["MailBox"].ToString(), (a) => { return true; });
It's working fine for four previous accounts. For the most recent account that I asked to be created, I get the dreaded error:
The Autodiscover service couldn't be located.
Our Exchange folks have sworn up and down that there is no difference between the new account and the others. But there must be something different, right? Does anyone know what it could be?
I activated the trace line above to get output in the console window (code is in a console app). While I could post the entire trace for the failing account, here are the response headers for the working accounts plus the non-working account. (Server names changed.)
Good accounts
<Trace Tag="AutodiscoverResponseHttpHeaders" Tid="1" Time="2018-01-29 21:24:45Z">
HTTP/1.1 200 OK
request-id: d291efce-7958-4faa-abbb-35c020f2780e
X-CalculatedBETarget: abc123.xrdom.xrcompany.firm
X-DiagInfo: abc123
X-BEServer: abc123
Persistent-Auth: true
X-FEServer: server02
Vary: Accept-Encoding
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Date: Mon, 29 Jan 2018 21:24:44 GMT
Set-Cookie: X-BackEndCookie=S-1-5-21-3649160047-1147056544-736230609-28825=u56Lnp2ejJqBm52cnsbJzJrSns3LxtLLns3G0saax5vSzM/LxpvHm8fJypqZgYHNz87H0s/N0s3Hq83Oxc3LxcvK; expires=Wed, 28-Feb-2018 21:24:45 GMT; path=/autodiscover; secure; HttpOnly
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
</Trace>
Bad Account:
<Trace Tag="AutodiscoverResponseHttpHeaders" Tid="1" Time="2018-01-29 21:21:49Z">
HTTP/1.1 401 Unauthorized
request-id: 99dfa551-c4c2-441b-a317-4f4fcba21a62
Server: Microsoft-IIS/8.5
WWW-Authenticate: Negotiate,NTLM,Basic realm="mail.xrcompany.com"
X-Powered-By: ASP.NET
X-FEServer: server01
Date: Mon, 29 Jan 2018 21:21:48 GMT
Content-Length: 0
</Trace>
What jumps out at me, besides the OK vs Unauthorized codes, is the different value for X-REServer.
Any help would be appreciated.