Evyatar
Evyatar

Reputation: 1157

EWS The Autodiscover service couldn't be located

I'm using C# EWS (ExchangeWebServices).
I have ExchangeServer i.e with the following IP: 10.81.5.1.
Now, I'm trying to access to ExchangeServer like the follow:

 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);

 service.Credentials = new WebCredentials("myuser", "mypassword", "10.81.5.1");
 service.TraceEnabled = true;
 service.TraceFlags = TraceFlags.All;
 service.AutodiscoverUrl("[email protected]", RedirectionUrlValidationCallback);//Throw an exception

And I got the following exception:

The Autodiscover service couldn't be located.

How i know my ExchangeServer domain?

When I'm changed the following (and run the code inside the ExchangeServer machine)

service.Credentials = new WebCredentials("myuser", "mypassword");

Meaning the domain is the localhost i'm success to run my code without exception.

What is the mistake at my code?

What i need to write instead "10.81.5.1" if I'm not running the code inside the ExchangeServer machine? How can i know my ExchangeServer "domain"?

Thanks.

Upvotes: 5

Views: 18325

Answers (3)

Anish Kutti
Anish Kutti

Reputation: 354

The following 3 lines worked for me:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials("<loginID..not email address>", "< the pw>");
service.AutodiscoverUrl("<your emailaddress>",RedirectionUrlValidationCallback);

If your login id is abc123. that's good enough. i need specify the domain

Upvotes: 2

Evyatar
Evyatar

Reputation: 1157

The reason of my problem was that the exchange server and my develop machine isn't on the same domain.
Solved by removed the follow line:

 service.AutodiscoverUrl("[email protected]", RedirectionUrlValidationCallback);//Throw an exception

And add the uri of the .asmx EWS :

service.Url = new Uri("https://IP/EWS/Exchange.asmx");

Upvotes: 5

neolei
neolei

Reputation: 1948

On my machine (win7), I can find it here: Control Panel - System - Computer name, domain and workgroup settings. Maybe you can have a try.

Upvotes: 0

Related Questions