[jcifs] NTLM Authentication for HTTP Connections on GlassFish (or any servlet container)

Allan Lykke Christensen allan.lykke.christensen at gmail.com
Fri Jun 26 09:58:33 GMT 2009

I've created a class that connects to an IIS website requiring NTLM
authentication. The Java class is based on the following example

Config.setProperty("jcifs.smb.client.domain", domain);
Config.setProperty("jcifs.smb.client.username", user);
Config.setProperty("jcifs.smb.client.password", password);

URL url = new URL("http://extsys/ems/");
BufferedReader reader = new BufferedReader(
            new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {

The example works fine when executed from the command prompt, but as soon as
I try to use the same code in a servlet container (specifically GlassFish),
I get an IOException containing the message "Server returned HTTP response
code: 401 for URL: ....".

I've tried moving the jcifs jar to the system classpath (%GLASSFISH%/lib),
but that doesn't seem to make any difference.

Using Java 1.6, jcifs 1.3.3 (also tried with 1.3.10), on Windows Server

Suggestions are highly appreciated.
View this message in context: http://www.nabble.com/NTLM-Authentication-for-HTTP-Connections-on-GlassFish-%28or-any-servlet-container%29-tp24217729p24217729.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.

More information about the jcifs mailing list