使用 Java Web 应用程序检测登录计算机的用户 [英] Detect user logged on a computer using Java web app

查看:23
本文介绍了使用 Java Web 应用程序检测登录计算机的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个可以检测登录 Windows 域的用户的 Java 应用程序.这些凭据将用于登录在 Tomcat 上运行的 Java 应用程序.

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.

我该怎么做?我想知道访问我的 Web 应用程序的远程用户.此用户已登录 Active Directory.

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

推荐答案

这是我的解决方案:

将 jcifs-1.2.7.jar 放在 [TOMCAT_HOME]/common/lib 目录下.

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

修改应用程序的 web.xml,将以下文本添加到 webapp 部分:

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>

并且您可以使用 request.getRemoteUser() 获取远程用户而无需提示.

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

见.

这篇关于使用 Java Web 应用程序检测登录计算机的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆