Using ActiveX to Get Username

I am working with an old intranet site written in classic ASP. I try to get their username with which they entered their car. Each user registers with AD, but I cannot get it from the server, since the intranet site does not use AD.

I was told that I can use ActiveX to get it. I did some research and found the following code (javascript):

var wshshell = new ActiveXObject("WScript.shell");
var username = wshshell.ExpandEnvironmentalStrings("%username%");

I am currently using IE8 and I am getting the error "Automation server error does not create object" in this first line.

1) Any ideas why I get the error?

2) Is there a better way to do this, subject to my limitations?

+3
source share
2 answers

If this is done on the client side, you must add the user to the Trusted Sites zone and set the protection level to the lowest level. Line 1 should work on the server side, but I don't think line 2 is true.

try it

var net = new ActiveXObject ( "WScript.NetWork" );
var username = net.UserName;
+6
source

In principle, it is not possible to obtain client information about a Windows computer using Javascript. Since its scope depends only on the browser.

To do this, you need to create a COM object or say an Activex object, and using an ASPX page you need to deploy it to the Client system the first time your page is accessible from a browser.

ActiveX javascript. COM- COM, . i.e .

var net = new ActiveXObject ( "WScript.NetWork" );
var username = net.UserName;

COM-, , script .

+1

Source: https://habr.com/ru/post/1713476/


All Articles