[jcifs] usage jcifs with servlets

Michael.Jagusch at it.nrw.de Michael.Jagusch at it.nrw.de
Fri Aug 14 05:28:23 MDT 2009


Hello,
 
i have the apprehension that this is really a littleness, but i have not found a good documentation for my problem.
i am trying to use jcifs to read userdata (login id only) in my servlet via the getRemoteUser() method. 
i have downloaded the version 1.3.11 of jcifs (tomcat 5.5, java 1.5.x) and already read the documentation and 
viewed the examples. But i really dont found an example for this standard problem. 
So i hope, you can give me a little help. 
In the documentation is described that the web.xml should be extended with the jcifs filters and the jcif[..].jar should be 
located in the lib directory of the servlet. Than the HttpServletRequest.getRemoteUser() method supplies the connected user.

My web.xml looks like that:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee <http://java.sun.com/xml/ns/j2ee> " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance> " xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee <http://java.sun.com/xml/ns/j2ee>  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd <http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd> ">
 <display-name>GetUserName</display-name>
 <filter>
  <filter-name>'NtlmHttpFilter'</filter-name>
  <filter-class>'jcifs.http.NtlmHttpFilter'</filter-class>
  <init-param>
   <param-name>jcifs.smb.client.domain</param-name>
   <param-value>[DOMAIN]</param-value>
  </init-param>
  <init-param>
   <param-name>jcifs.netbios.wins</param-name>
   <param-value>[IP]</param-value>
  </init-param>
  <init-param>
   <param-name>jcifs.http.domainController</param-name>
   <param-value>[IP]</param-value>
  </init-param>
  <init-param>
   <param-name>jcifs.smb.client.username</param-name>
   <param-value>[USER]</param-value>
  </init-param>
  <init-param>
   <param-name>jcifs.smb.client.password</param-name>
   <param-value>[PASSWORD]</param-value>
  </init-param>
 </filter><filter-mapping>
  <filter-name>NtlmHttpFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping><servlet>
  <description>
  </description>
  <display-name>CGetUserName</display-name>
  <servlet-name>CGetUserName</servlet-name>
  <servlet-class>
  CGetUserName</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>CGetUserName</servlet-name>
  <url-pattern>/CGetUserName</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>default.html</welcome-file>
  <welcome-file>default.htm</welcome-file>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>
</web-app>
 
The Servlet reads only the remote user:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	PrintWriter out = response.getWriter();
	response.setHeader("Location",request.getRequestURI());
	response.setContentType("text/html");
	out.println("Remote User: " + request.getRemoteUser() + "<BR>");
	out.close();
}



When i use the standard web.xml, i can access the servlet - successfully. When i am use the extended web.xml with
the jcifs filters i get the message 404 "The Requested resource [..] not available". In the examples directory 
the web.xml doesnt contain the servlet Tags, when i remove this i get logically the same message from tomcat. 
So the web.xml doesnt correspond to the given servlet example.

Has anybody experience in that, any idea or a good documentation, how to use jcifs within a servlet?

Many thanks in advance.

Michael Jagusch


More information about the jCIFS mailing list