问题描述
我写在传统的ASP的旧内部网站的工作。我想找回自己的用户名登录,他们到他们的机器。每个用户登录到广告,但我无法从服务器检索它,因为Intranet站点不使用AD。
I'm working with an old intranet site written in classic ASP. I'm trying to retrieve their username they logged into their machine with. Each user is logged into AD, but I can't retrieve it from the server since the intranet site does not use AD.
有人告诉我,我可以为了找回它使用ActiveX。我做了一些研究,我发现下面的code(JavaScript的):
I was told I could use ActiveX in order to retrieve it. I did some research and I found the following code (javascript):
var wshshell = new ActiveXObject("WScript.shell");
var username = wshshell.ExpandEnvironmentalStrings("%username%");
目前我使用IE8和我得到一个上第一行的自动化服务器不能创建对象的错误。
Currently I'm using IE8 and I get an "Automation server can't create object" error on that first line.
1)任何想法,为什么我得到这个错误吗?
1) Any ideas why I'm getting the error?
2)是否有更好的方式来这样做给我的限制?
2) Is there a better way to be doing this given my limitations?
推荐答案
如果这是在客户端完成,那么你必须有用户的站点添加到受信任的站点区域,将安全级别设置到最低。 1号线应该工作的服务器端,但我不认为2号线是正确的。
If this is done client-side, then you must have the user add the site to the Trusted Sites zone and set the security level to the lowest. Line 1 should work server-side, but I don't think line 2 is right.
试试这个
var net = new ActiveXObject ( "WScript.NetWork" );
var username = net.UserName;
这篇关于使用ActiveX来获得用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!