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

时间:2022-09-25 23:22:23

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.

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

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.

我尝试过使用System.getProperty(“user.name”),但是当我从其他机器(客户端)访问应用程序时,这仍然显示服务器上登录用户的用户名。我希望每次都根据客户端机器用户名进行更改。

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

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

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

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

Application Details:

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

视图:Struts应用程序框架:Spring 3.1.1应用程序服务器:jboss-6.1.0。最终服务器操作系统:CentOS 5

3 个解决方案

#1


0  

Through java you will not be able to access it since it resides in server. You will have to use javascript to get it done...

通过java,您将无法访问它,因为它驻留在服务器中。你将不得不使用JavaScript来完成它...

This might help you..

这可能对你有帮助..

Get Windows username with JavaScript?

用JavaScript获取Windows用户名?

#2


0  

For security purposes the amount of data applications running in a browser can access is limited. As far as I know, the only thing which is allowed access to client related data would be a Signed Applet.

出于安全考虑,浏览器中运行的数据应用程序的数量有限。据我所知,唯一允许访问客户端相关数据的是签名小程序。

#3


0  

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

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

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

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

#1


0  

Through java you will not be able to access it since it resides in server. You will have to use javascript to get it done...

通过java,您将无法访问它,因为它驻留在服务器中。你将不得不使用JavaScript来完成它...

This might help you..

这可能对你有帮助..

Get Windows username with JavaScript?

用JavaScript获取Windows用户名?

#2


0  

For security purposes the amount of data applications running in a browser can access is limited. As far as I know, the only thing which is allowed access to client related data would be a Signed Applet.

出于安全考虑,浏览器中运行的数据应用程序的数量有限。据我所知,唯一允许访问客户端相关数据的是签名小程序。

#3


0  

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

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

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

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