ActiveXObject(“ADSystemInfo”) 上的错误

发布于 2024-12-08 11:51:35 字数 482 浏览 1 评论 0原文

我的 JavaScript 上有这一行当

var objSysInfo=new ActiveXObject("ADSystemInfo");
var objUser=GetObject("LDAP://" + objSysInfo.UserName);
alert(objUser.displayName);

我以管理员身份登录时,一切正常,但如果我以非管理员帐户登录,它就会开始给出异常,说明

var objSysInfo=new ActiveXObject("ADSystemInfo");

这里似乎存在问题,我将如何解决它? 有没有其他方法可以从 javascript 获取用户信息,我只想获取显示名称? (我知道这在 FF 和 Chrome 上不起作用)

顺便说一句,这是我得到的错误“自动化服务器无法创建对象活动 x”

I have this line on my JavaScript

var objSysInfo=new ActiveXObject("ADSystemInfo");
var objUser=GetObject("LDAP://" + objSysInfo.UserName);
alert(objUser.displayName);

When I am logged in as an admin everything works fine, but if I am logged in as a non-admin account it starts to give exception on

var objSysInfo=new ActiveXObject("ADSystemInfo");

what seems to be the problem here and how will I solve it?
Are there any other alternatives to get the User Info from javascript, I just want to get the display name? (I know this wont work on FF and Chrome)

BTW this is the error I Get "automation server can't create object active x"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独陪着我 2024-12-15 11:51:35

该错误表明当前用户的浏览器安全设置可能不允许该特定 ActiveX 控件的实例化。除非您可以更改用户的浏览器安全设置,否则您实际上无法以编程方式(使用 JavaScript)对此进行任何操作。

您不会收到与管理员用户相同的错误,可能是因为安全设置更宽松。

尝试使用“Internet 选项”中的 ActiveX 安全设置,看看是否可以使其与非管理员用户一起使用。也许最终用户的解决方案是提供有关如何更改 ActiveX 安全设置的文档。

The error indicates that the browser security settings of the current user probably don't permit the instantiation of that particular ActiveX control. Unless you can change the browser security settings of the user, there's really nothing you can do about it programmatically (using JavaScript).

You don't get the same error as an admin user probably because of more lax security settings.

Try playing around with the ActiveX security settings in Internet Options and see if you can get it to work with the non-admin user. Maybe the solution for your end users is to provide documentation on how to change the ActiveX security settings.

桃扇骨 2024-12-15 11:51:35

我知道这个问题几年前就被问过。但是,我回答是为了以防万一有人可能需要此信息:

您可能想使用更像这样的东西:

**JavaScript**
    var wshshell = new ActiveXObject("wscript.shell");
    var userName = wshshell.ExpandEnvironmentStrings("%username%");
    alert(userName);

**VBScript**
    Set ObjSysInfo = CreateObject("ADSystemInfo")
    strUser = objSysInfo.UserName

    Set objUser = GetObject("LDAP://" & strUser)
    Dim userName = objUser.SAMAccountName
'In this case, username will be populated with whatever the AD requires for 
'authentication when logging in

也许这对您有用?

I know that this question was asked a few years ago. However, i am answering just in case someone might need this information:

You might want to use something more like this:

**JavaScript**
    var wshshell = new ActiveXObject("wscript.shell");
    var userName = wshshell.ExpandEnvironmentStrings("%username%");
    alert(userName);

**VBScript**
    Set ObjSysInfo = CreateObject("ADSystemInfo")
    strUser = objSysInfo.UserName

    Set objUser = GetObject("LDAP://" & strUser)
    Dim userName = objUser.SAMAccountName
'In this case, username will be populated with whatever the AD requires for 
'authentication when logging in

Maybe that'll work for you??

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文