使用JAVA或JSP获取Windows用户名 [英] Get windows username using JAVA or JSP

查看:154
本文介绍了使用JAVA或JSP获取Windows用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows上记录用户名,我的意思是用户使用java登录到Windows。我使用
System.getProperty(user.name); 但是我得到了服务器名,而不是用户。

I want to get logged username on windows , I mean the user logged in to windows using java. I used System.getProperty("user.name"); but I got the server-name, not the user.

推荐答案

获取登录到您的Web应用程序的用户的名称(根据您的评论,我认为您想要做的事情)完全取决于您的拥有方式在您的系统中实施身份验证但是,如果您的登录机制添加了此信息,则用户名可能在 request.getRemoteUser() request.getUserPrincipal() 。但如上所述,这一切都取决于。您的身份验证机制可能会暴露这种情况,但是我们需要更多信息来帮助。

Getting the name of the user logged into your web application (which I think is what you want to do, based on your comments) entirely depends on how you have implemented authentication in your system. However, if your login mechanism adds this information, the username might be available in request.getRemoteUser() or request.getUserPrincipal(). But as mentioned, it all depends. Your authentication mechanism might expose this otherwise, but then we would need more information to assist.

System.getProperty(user.name)只会给你运行java进程的用户的用户名。

System.getProperty("user.name") will only give you the username of the user running the java process.

这篇关于使用JAVA或JSP获取Windows用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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