4

I am developing a application in java to get email attachmants from exchange server (version 10), i have windows 7 (32bit) pc. my code is compiling successfully but giving error at run time, saying-

May 20, 2013 5:58:46 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: NTLM authentication scheme selected
May 20, 2013 5:58:47 PM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: Failure authenticating with NTLM <any realm>@autodiscover.mydomain.com:443


and my code is -

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
    ExchangeCredentials credentials;
    credentials = new WebCredentials("myuser", "mypwd","mydomain");
    service.setCredentials(credentials);
    service.autodiscoverUrl("user@domain.com");

how to solve this NTLM authentication error?

Apurv
  • 3,723
  • 3
  • 30
  • 51
yugalkishorbais
  • 119
  • 1
  • 11

2 Answers2

0

Enable Trace : service.setTraceEnabled(true); Are you sure your Exchange version is 2010 ? use this guide to check

also try removing service.autodiscoverUrl("user@domain.com");

Community
  • 1
  • 1
Raj
  • 497
  • 4
  • 8
0

In my case, it was an incorrect order of auth preferences. I just changed them by editing the code. I'm using EX_2007_SP3.

In microsoft.exchange.webservices.data.HttpClientWebRequest:prepareConnection() and prepareAsyncConnection() methods, I changed the auth preference order

from,

authPrefs.add(AuthPolicy.NTLM);
authPrefs.add(AuthPolicy.BASIC);
authPrefs.add(AuthPolicy.DIGEST);

to,

authPrefs.add(AuthPolicy.BASIC);
authPrefs.add(AuthPolicy.NTLM);
authPrefs.add(AuthPolicy.DIGEST);

And it is still working :) I have seen some of developers use NEGOTIATE too.

Hope this helps.

sura2k
  • 7,365
  • 13
  • 61
  • 80