Pergunta

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();
}
Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top