Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 262
Evyatar Avatar asked Aug 11 '16 07:08

Evyatar


People also ask

What is EWS Autodiscover?

Autodiscover works for client applications inside and outside firewalls and in resource forest and multiple forest scenarios. For EWS clients, Autodiscover is typically used to find the EWS endpoint URL, but Autodiscover can also provide information to configure clients that use other protocols.

How do I find Autodiscover in Exchange?

Find autodiscover URL with PowerShell Get the configured autodiscover URL on the Exchange Servers. Run Exchange Management Shell as administrator and run the Get-ClientAccessServer cmdlet. The output will show all the Exchange Servers, including the autodiscover URL (AutoDiscoverServiceInternalUri). That's it!


2 Answers

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");
like image 172
Evyatar Avatar answered Nov 15 '22 03:11

Evyatar


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

like image 32
Anish Kutti Avatar answered Nov 15 '22 04:11

Anish Kutti