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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With