Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting NT/2000 Username

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

Can anyone tell me how to get the NT/2000 user login name from an IE Browser on a MS client?

Thanks,

Michael42
 
The code is as follows:
<SCRIPT TYPE=&quot;text/VBScript&quot;>
<!--
Dim objNet
On Error Resume Next
Set objNet = CreateObject(&quot;WScript.NetWork&quot;)
Dim strInfo
strInfo = &quot;UserName is &quot; & objNet.UserName & vbCRLF & _
&quot;ComputerName is &quot; & objNet.ComputerName & vbCRLF & _
&quot;DomainName is &quot; & objNet.UserDomain
MsgBox strInfo
//-->
</SCRIPT>
 
The short answer is:
request.servervariables(&quot;LOGON_USER&quot;)

If you put the following on an ASP page you will get a list of all variables and their values:

<h2>Request Server Variables List</h2>
<%
Dim V
response.Write &quot;<Table>&quot;
For Each V in Request.ServerVariables
Response.Write &quot;<TR><TD VAlign='top'><b>&quot; & V & &quot;</b></TD><TD VAlign='top'>&quot; & Request.ServerVariables(V) & &quot;</Font></TD></TR>&quot;
Next
Response.Write &quot;</Table>&quot;

%>
 
Hi DJS2,
I have put the code as you suggested into a asp file but it doesn't work. I just get the heading Request Server Variables List on the screen. Do I have to add anything else to the file?

Thanks

James
 
Hi James,

I assume that your web server is configured for ASP?

I'm using IIS5 (it also works on IIS4) and the code is hand-written in Front Page 2000. It is a standard ASP page written in VBScript. I use it all of the time to test connections.

I hope that this helps.

David

 
This is the full page script that I use:....
============================================================

<%@Language='vbscript'%>
<% Option Explicit %>


<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>Server Variables</title>
</head>

<body>

<h2>Request Server Variables List</h2>
<%
Dim V
response.Write &quot;<Table>&quot;
For Each V in Request.ServerVariables
Response.Write &quot;<TR><TD VAlign='top'><b>&quot; & V & &quot;</b></TD><TD VAlign='top'>&quot; & Request.ServerVariables(V) & &quot;</Font></TD></TR>&quot;
Next
Response.Write &quot;</Table>&quot;

%>

</body>

</html>

============================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top