Question

I am using EWSJavaAPI 1.1.5. I am trying to login with invalid credentials, but I don't get any exceptions.

Please advise how to detect and handle invalid login.

Here is my code:

String host = "myhost";
ExchangeService service = null;
try {
    service = new ExchangeService();
    ExchangeCredentials credentials = new WebCredentials("wrongemail",
        "wrongpass");
    service.setCredentials(credentials);
    service.setUrl(new java.net.URI("https://" + host
        + "/EWS/Exchange.asmx"));
} catch (Exception e) {
    e.printStackTrace();
}
Était-ce utile?

La solution

Found it, i had to bind the service to a folder:

Folder.bind(service, WellKnownFolderName.Inbox);

and if the credentials are wrong, HttpErrorException is thrown.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top