如何在Java中获取客户端计算机上当前登录用户的用户名?

问题描述:

当用户(客户端)尝试通过键入URL进入应用程序时,我需要以用户名登录该计算机的Windows。

When the user (client) tries to get into the application by typing the URL, i need to get that machine's windows logged in username.

我试过 System.getProperty(user.name)但是当我从某些人那里访问应用程序时其他机器(客户端)然后这仍然显示在服务器上登录用户的用户名。我希望每次都根据客户端计算机用户名进行更改。

I have tried with System.getProperty("user.name") but when I access the application from some other machine (client) then this still shows username of logged in user on server. I want this is to be changed according to the client machine username every time.

我也试过一些JavaScript代码,它只适用于IE但我们正在使用Firefox。

And also I have tried with some JavaScript code, it only works on IE but we are using Firefox.

请建议使用各种浏览器的可行方法。

Kindly suggest the possible ways to work with all kind of browsers.

申请详情

查看: Struts

应用程序框架: Spring 3.1.1

应用程序服务器: jboss-6.1.0.Final

服务器操作系统: CentOS 5

View: Struts
Application Framework: Spring 3.1.1
Application Server: jboss-6.1.0.Final
Server OS: CentOS 5

如果这是用于Intranet应用程序,您可以查看使用NTLM(较旧)或Kerberos(较新)身份验证(也称为集成Windows身份验证)。

If this is for an intranet application, you can look at using NTLM (older) or Kerberos (newer) authentication (aka integrated windows authentication).

如果您使用的是Spring安全性,请查看kerberos扩展, http://blog.springsource.org/2009/09/28/spring-security-kerberos/

If you're using Spring security, look at the kerberos extension, http://blog.springsource.org/2009/09/28/spring-security-kerberos/.