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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find user name of my pc in a asp page

Status
Not open for further replies.

giginge

Technical User
Jul 9, 2003
13
0
0
IT
Hello,
With this code in vbscript:


Set WshNetwork = WScript.CreateObject("WScript.Network")

WScript.Echo "User = " & WshNetwork.UserName


I have the name of the user in my pc.
How can I do to have this information using an ASP page?

Thanks at all and sorry for my English.
 

In ASP, you can write:
Code:
	Set n = Server.CreateObject("WScript.Network")
	Response.Write n.UserName
	
	Set n = Nothing
It worked on my server anyway...

Hope this helps,
Elijah
 
Thanks for your help, now It's all ok.
 
Interesting, was this supposed to return the login account name for the machine (domain\randomUser) or the IUSR account that ASP uses for website vistors?
 
Ahh, interesting q. I wasn't even aware of wScript until giginge had asked about it. I tested the script with the following results:

Run on our corp intranet with integrated windows authentication enabled in IIS, it returned my username on my local machine.

Run on our public web server, it returned the asp process username, IUSR_Machinename

So there you go!

Elijah
 
Why when I run this part of code:


Dim wshNetwork
Set wshNetwork = CreateObject("WScript.Network")
strUser = wshNetwork.Username
strDomain= wshNetwork.UserDomain



The pc show this error messagg:

The ActiveX Component can't create the "Wscript.Network" object????

Thanks






 
If the CreateObject("WScript.Network") doesnt work look in registry for the WScript.Network and see what is it's full name.
And if doesnt work also then you have no access to create ActiveX Objects on IIS


________
George, M
 
If I have no access to create ActiveX Objects on IIS, what can I do?
 
Are you using an hosting service? or your own computer?

________
George, M
 
That's weird. Did you tryed WScript.Network.1 instead of WScript.Network?


________
George, M
 
I tryed it now...but it doesn't work.
If I use an host service, what can I do?
Thanks for your help, and sorry for all the disturb.
 
1 more thing.
did you run this as asp or as vbscript in an html page?

________
George, M
 
I'm running this script like vbscript in an html page
 
Well that's the problem in html scripts you cant use ActiveX directly(security issue) you have to enable ActiveX from the IE or just run the code as vbs file or as ASP code

________
George, M
 
When I use this code in a .vbs file it's all ok, but in a html page it's not work. Why?
 
scripts you cant use ActiveX directly (security issue) you have to enable ActiveX from the browser.

________
George, M
 
It's important to note that if it is client-side code (embedded vbscript in an html page), it will be running on the client machine, and cannot return information about the server logon...

Elijah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top