[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
	{
		super.init(config);
		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"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

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

    <servlet>

        <servlet-name>SimpleNtlmServlet</servlet-name>
        <servlet-class>SimpleNtlmServlet</servlet-class>

        <init-param>
            <param-name>jcifs.smb.client.domain</param-name>
            <param-value>IBM</param-value>
        </init-param>

        <init-param>
            <param-name>jcifs.netbios.wins</param-name>
            <param-value>192.168.1.100</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>SimpleNtlmServlet</servlet-name>
        <url-pattern>/SimpleNtlmServlet</url-pattern>
    </servlet-mapping>


</web-app>

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


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


any suggestions would be helpful

thanks

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 
>currently
>
>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, 
>It
>
>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*
>http://join.msn.com/?page=features/junkmail
>
>
>
>DISCLAIMER: This communication and any files or attachments transmitted 
>with
>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*  
http://join.msn.com/?page=features/junkmail




More information about the jcifs mailing list