Access IE USERNAME for use in Javascript

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on an internal web application that needs minimal security, but
I do want to include some authorization. To authenticate users, I would like
to simply retrieve the current user name from Internet Explorer and pass it
into the application by using JavaScript to populate a hidden text field on
the form of the web page.
Is the current username accessible by some means? ... accessible to
JavaScript???
Fingers crossed and thanks, Terry
 
Hi Terry,
Heres a menu script
<script language="javascript">

var wshShell = new ActiveXObject("WScript.Shell");
var sdomain = wshShell.ExpandEnvironmentStrings("%USERDOMAIN%");
var sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%");
var sComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%");
alert('Domain= ' + sdomain + '\nUserName= ' + sUserName + '\nComputer Name=
' + sComputerName);
</script>

Just replace the alert line with something like
var logurl='http://mycompanyserver.com/login.aspx?txtUserName=' +
escape(sUserName);
window.open(logurl);

If you want the script made into a button or placed on a home/start page let
me know (mailto:[email protected] ) ...... I could use the work...

See my website http://www.iecustomizer.com for more IE utilities and addons.

Regards.
 
Rob,
Thanks. You've definitely pointed me in the right direction. Sorry not
to reply sooner, but I got pulled off on to a couple of top priority jobs.
Googling parts of the script you sent, it looks fine. However, I spent
half a day tweaking and mangling the code and was never able to get the first
line (ends with WScript.Shell) to not generate an error. Having tried so
many variants, I suspect our security system may be preventing the
instantiation. I will dig into that next.
Thanks again for showing me where the ballpark is.
Terry
 
Back
Top