获取客户端 Windows 用户名 [英] Get client windows username

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

问题描述

我可以使用小程序获取当前被盗用户的用户名吗?如果是,我如何在我的动态 Web 项目中使用小程序?我知道在 I.E 中我们可以这样做

Can i get the username of the currently looged in person using applets. If yes, how can i use the applet in my dynamic web project? I know in I.E we can do like this

var objUserInfo = new ActiveXObject("WScript.network");
document.write(objUserInfo.ComputerName+"<br>"); 
document.write(objUserInfo.UserDomain+"<br>"); 
document.write(objUserInfo.UserName+"<br>");  
var uname =  objUserInfo.UserName;
alert(uname);

但我希望它使用小程序,以便它可以在任何浏览器中运行.

but i want it using applet so that it will work in any browser.

推荐答案

请注意,这实际上是一种绕过浏览器安全性的尝试.看看这个类似(但不完全相同)问题的答案.http://www.coderanch.com/t/243316/Applet/java/windows-NT-login-applet

Be aware that this is in fact an attempt to circumvent the browser security. look at the answer to this similar (but not excactly the same) question. http://www.coderanch.com/t/243316/Applets/java/windows-NT-login-applet

  • ActiveX 将无法在 Chrome/Firefox 中正常运行.
  • Javascript 不会(出于安全原因)允许您从操作系统获取该信息.
  • Flash 是跨浏览器的,可以用于此目的,但很难绕过 chromes 沙箱.
  • ActiveX will not run properly in Chrome / Firefox.
  • Javascript won't (due to security reasons) allow you to get that information from the operating system.
  • Flash is cross browser, and can be used for this, but it is difficult to get around chromes sandbox.

所以我最好的建议是 java.

so my best suggestion is java.

这里有一个类似的问题,回答了为什么没有小程序就不能.https://security.stackexchange.com/问题/36728/can-your-windows-or-linux-username-be-exposed-to-websites

Here is a similar question that is answered on why you can't without an applet. https://security.stackexchange.com/questions/36728/can-your-windows-or-linux-username-be-exposed-to-websites

并且从另一个类似问题的答案中提供的链接指向一个 java 解决方案,但成功是有限制的:http://www.rgagnon.com/javadetails/java-0441.html

And the provided link from an answer to another similar question points to a java solution, but there are limits to the success: http://www.rgagnon.com/javadetails/java-0441.html

但是我认为你应该从那里开始,然后在它起作用时在此处发布解决方案;)

However I think you should start from there, and then post a solution here when it works ;)

这里看到的问题是,当小程序试图与本地资源交互时,浏览器必须允许它,或者阻止它.IE 中的安全设置,如果设置为高可能会阻止它,如果你做错了,Chromes 沙箱可能会阻止它.我不知道 Firefox 或 Safari 有什么问题,但我想你会在测试时发现它们......

See the problem here is that when the applet tries to interact with local resources the browser must allow it, or block it.. Security settings in IE, may prevent that if set to high, and Chromes sandbox may block it if you do it wrong. I don't know of problems with Firefox or Safari, but I guess you'll find them when testing...

祝你好运.

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

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