Tuesday, October 3, 2023
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  132] [ 6]  / answers: 1 / hits: 17295  / 15 Years ago, fri, july 24, 2009, 12:00:00

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?


More From » asp-classic

 Answers
24

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;

[#99062] Tuesday, July 21, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maryann

Total Points: 600
Total Questions: 104
Total Answers: 97

Location: Sint Maarten
Member since Tue, Mar 29, 2022
2 Years ago
;