[jcifs] Problem with NtlmServlet

dave mobley scprotz at hotmail.com
Fri Jun 13 07:21:15 EST 2003

The following is a servlet and my web.xml file.  Using a slightly different 
setup (the web.xml file uses the filter, and the servlet subclasses the 
regular javax.servlet.http.HttpServlet), this will authenticate via ntlm.

/****************  SimpleNtlmServlet *******************************/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SimpleNtlmServlet extends jcifs.http.NtlmServlet

	public void init(ServletConfig config)
		throws ServletException
		System.out.println("Initializing Servlet");

	public void doGet( HttpServletRequest req, HttpServletResponse resp )
                throws IOException, ServletException
    	System.out.println("Doing GET");

        PrintWriter out = resp.getWriter();

        resp.setContentType( "text/html" );
        out.println( "<HTML><HEAD><TITLE>NTLM HTTP Authentication 
Example</TITLE></HEAD><BODY>" );
        out.println( "<h2>NTLM HTTP Authentication Example</h2>" );

        out.println( req.getRemoteUser() + " successfully logged in" );

        out.println( "</BODY></HTML>" );

    public void doPost( HttpServletRequest req,
                HttpServletResponse resp ) throws IOException, 
ServletException {
        doGet( req, resp );

/****************  SimpleNtlmServlet *******************************/

<!------------------ web.xml ------------------------------------------>

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"


    <display-name>Simple Ntlm Servlet</display-name>
    <description>Simple Ntlm Servlet</description>








<!------------------ web.xml ------------------------------------------>

Note: my domain is IBM.  The name of the server with active directory is 
pdc.ibm.com at

any suggestions would be helpful


dave mobley
scprotz at hotmail.com

>From: Nathan Zentner <Nathan.Zentner at paccoast.com>
>To: 'dave mobley' <scprotz at hotmail.com>
>Subject: RE: [jcifs] Problem with NtlmServlet
>Date: Thu, 12 Jun 2003 13:50:07 -0700
>How have you extended the servlet.  If you are overwriting a method that it
>does all the work in, then that is your problem.
>Attach some code next time.
>-----Original Message-----
>From: dave mobley [mailto:scprotz at hotmail.com]
>Sent: Thursday, June 12, 2003 1:47 PM
>To: jcifs at lists.samba.org
>Subject: [jcifs] Problem with NtlmServlet
>I am trying to get a simple servlet to authenticate via ntlm.
>I have tried to get the jcifs.http.NtlmServlet class to work (I am 
>using tomcat 4.1.18).  I can get the servlet to work if i use the
>NtlmHttpFilter, but for some reason, if I subclase the NtlmServlet class, 
>will not work (always returns 'null' logged in).
>I have read through the source code, and the NtlmServlet and the
>NtlmHttpFilter are nearly identical.  I am trying to get this to work
>against a Win2k server (running active directory).
>Has anyone gotten the NtlmServlet to work (and if so, could you send me a
>sample working servlet or war file with a servlet?)
>Thanks very much,
>Dave Mobley
>scprotz at hotmail.com
>The new MSN 8: smart spam protection and 2 months FREE*
>DISCLAIMER: This communication and any files or attachments transmitted 
>it may contain information that is copyrighted or confidential and exempt
>from disclosure under applicable law.  It is intended solely for the use of
>the individual or the entity to which it is addressed.  If you are not the
>intended recipient, you are herby notified that any use, dissemination, or
>copying of this communication is strictly prohibited.  If you have received
>this communication in error, please notify us at once so that we may take
>the appropriate action and avoid troubling you further. Thank you for your
>cooperation. Contact information: Pacific Coast Company Inc. 1-916-971-2330
>and ask for the e-mail administrator.

The new MSN 8: advanced junk mail protection and 2 months FREE*  

More information about the jcifs mailing list