Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect user logged on a computer using Java web app

I want to develop an Java application that can detect the user logged on a Windows Domain. These credentials are going to be used to logging on the Java application running on Tomcat.

How can I do this? I want to know the remote user accessing my web app. This user is logged on in Active Directory.

like image 881
VansFannel Avatar asked Apr 07 '09 15:04

VansFannel


1 Answers

This is my solution:

Put jcifs-1.2.7.jar on [TOMCAT_HOME]/common/lib directory.

Modify application's web.xml adding the followin text to section webapp:

<filter>
    <filter-name>NtlmHttpFilter</filter-name>
    <filter-class>jcifs.http.NtlmHttpFilter</filter-class>
    <init-param>
        <param-name>jcifs.http.domainController</param-name>
        <param-value>xx.xx.xx.xxx</param-value>  --> Domain Controller IP
    </init-param>
    <init-param>
        <param-name>jcifs.util.loglevel</param-name>
        <param-value>2</param-value>
    </init-param>
  </filter>
  <filter-mapping>
       <filter-name>NtlmHttpFilter</filter-name>
       <url-pattern>/*</url-pattern>
  </filter-mapping>

And the you can get the remote user using request.getRemoteUser() whithout prompt.

See you.

like image 96
VansFannel Avatar answered Sep 19 '22 02:09

VansFannel