axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gangel <gan...@o2.pl>
Subject NTLM user\domain plus port number
Date Mon, 22 Feb 2010 13:39:19 GMT

Hi, 
i'm pulling my hair of my head because of this issue. I'm sure there is
someone who knows the answer:

trying to connect from Java code to Sharepoint using web service(Sharepoint
uses Active Directory and NTLM). I'm getting the 401:Authentication error. I
know that this subject was talked through but my code is still not working.

I was thinking that maybe the problem is with the fact that my user name is
in domain and that the machine is available under some port number. Do I
have to use ProxyProperties when using NTLM authentication?Is it better to
use NTCredentials? Please, look at the code below, maybe you have some idea:

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import com.microsoft.schemas.sharepoint.soap.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.commons.httpclient.auth.AuthPolicy;

public class Test {
	public static void main(String[] args) {
		HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
		auth.setUsername ("DOMAIN\\user");
		auth.setPassword ("pass");
		auth.setDomain ("DOMAIN");
		auth.setHost("host");
		auth.setPort(8888);
		auth.setPreemptiveAuthentication(true);
		List<String> authPrefs = new ArrayList<String>(1);
		authPrefs.add((String)AuthPolicy.NTLM);
		auth.setAuthSchemes (authPrefs);
		ListsStub lists;
			try {
				lists = new ListsStub();
				lists._getServiceClient ().getOptions().setProperty
(HTTPConstants.AUTHENTICATE, auth);
				Options options = lists._getServiceClient().getOptions();
				options.setSoapVersionURI(Constants.URI_SOAP11_ENV);
				ListsStub.GetListCollection req = new ListsStub.GetListCollection();
				ListsStub.GetListCollectionResponse res;
				System.out.println();
				res = lists.GetListCollection (req);
				System.out.println(res.toString());
			} catch (AxisFault e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (RemoteException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
}

-- 
View this message in context: http://old.nabble.com/NTLM-user%5Cdomain-plus-port-number-tp27687293p27687293.html
Sent from the Axis - Dev mailing list archive at Nabble.com.


Mime
View raw message