问题描述
我正在处理一个用经典 ASP 编写的旧 Intranet 站点.我正在尝试检索他们登录机器时使用的用户名.每个用户都登录到 AD,但我无法从服务器检索它,因为 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 来检索它.我做了一些研究,发现了以下代码(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 获取用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)