[jcifs] 400 Response on NtlmHttpURLConnection
korong
pan.pur at gmail.com
Sun Oct 31 07:31:15 MDT 2010
Hello, I'm trying to connect to Windows 2008 WinRM using Negotiate/NTML
authentication based on this guide:
http://jcifs.samba.org/src/docs/httpclient.html
However I got 400 (Bad Request) response from the server. It works fine if I
use standard java HttpUrlConnection and Basic Authentication. Here's my
source code:
Config.setProperty("jcifs.smb.client.domain", ""); // i'm on
workgroup
Config.setProperty("jcifs.smb.client.username", user);
Config.setProperty("jcifs.smb.client.password", password);
Config.registerSmbURLHandler();
try {
Config.setProperty("jcifs.netbios.hostname",
Config.getProperty("jcifs.netbios.hostname",
InetAddress.getLocalHost().getHostName()));
} catch (Exception ex) {
}
URL url = new URL(location);
NtlmHttpURLConnection conn = new
NtlmHttpURLConnection((HttpURLConnection) url.openConnection());
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", msg.length() + "");
conn.setRequestProperty("Connection", "keep-alive");
conn.setRequestProperty("Content-type",
ContentType.createFromEncoding((String)
soap.getProperty(SOAPMessage.CHARACTER_SET_ENCODING)).toString());
OutputStreamWriter out = new OutputStreamWriter(
conn.getOutputStream());
out.write(msg);
out.close();
BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
Please enlighten me about this. Thank you.
--
View this message in context: http://samba.2283325.n4.nabble.com/400-Response-on-NtlmHttpURLConnection-tp3021092p3021092.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.
More information about the jCIFS
mailing list