Using ActiveX to get username(使用 ActiveX 获取用户名)
问题描述
我正在处理一个用经典 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 获取用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 ActiveX 获取用户名


- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01