Hello all, I have been developing an ExchangeWebServices client using axis2 (xmlbeans), and cannot seem to get NTLM working. Basic Authentication is working.
I have a class that extends the generated stub. It has a constructor public ExchangeWebServiceBinding(String userName, String passWord, boolean secure, String ewsPath, String host, String ntDomain, int port) throws RemoteException { super(createTargetEndPointUrl(ewsPath, secure, host, port, ewsPath)); setAuthenticationParameters(userName, passWord, host, ntDomain, port); } The setAuthenticationParameters does the authentication: private void setAuthenticationParameters(String userName, String passWord, String host, String ntDomain, int port) throws RemoteException { Protocol AlcHttpsProtocol = new Protocol(HTTPS, new EasySSLProtocolSocketFactory(), port); Protocol.registerProtocol(HTTPS, AlcHttpsProtocol); Options options = this._getServiceClient().getOptions(); HttpTransportProperties.Authenticator ntlmAuthentication = new HttpTransportProperties.Authenticator(); ntlmAuthentication.setUsername(userName); ntlmAuthentication.setPassword(passWord); ntlmAuthentication.setHost(host); ntlmAuthentication.setPort(port); ntlmAuthentication.setRealm(null); ntlmAuthentication.setDomain(ntDomain); ntlmAuthentication.setAllowedRetry(true); ArrayList authSchemes = new ArrayList(); authSchemes.add(AuthPolicy.NTLM); ntlmAuthentication.setAuthSchemes(authSchemes); options.setProperty(HTTPConstants.AUTHENTICATE, ntlmAuthentication); // Set to 5 minutes options.setTimeOutInMilliSeconds(300000); this._getServiceClient().setOptions(options); logger.info("Authentication parameters set for user [" + userName + "]"); } I have setup SBS2008 with "Windows Authentication" enabled on the SERVER\Sites\SBS Web Applications\EWS folder, and all others disabled. I keep getting 401 errors. If I change the AuthPolicy.NTLM to AuthPolicy.BASIC, and enable BASIC on the server it works. Does anyone have any ideas? Is what I am doing above correct? or is there another way? Thanks Andrew P.S. Also, http://ws.apache.org/axis2/1_3/http-transport.html talks about NTCredentials. Do I need to use these? How to I set them in the stub?