views:

724

answers:

1

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.

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%");

Currently I'm using IE8 and I get an "Automation server can't create object" error on that first line.

1) Any ideas why I'm getting the error?

2) Is there a better way to be doing this given my limitations?

+1  A: 

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.

Try this

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