Display username and hostname on Intranet

B

Bob Lin

I would like to display the hostname (or computername) and username (or
logonID) on our Intranet support page. I saved the following vbs code as asp
file, but it doesn't display the username. No error also. Do I miss some
thing?

dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
strUserDomain = objNetwork.UserDomain
Wscript.Echo "User " & objNetwork.UserName

Networking, Internet, Routing, VPN, Anti-Virus, Tips & Troubleshooting on
http://www.ChicagoTech.net
This posting is provided "AS IS" with no warranties.
 
B

Bob Lin

Hi Ray,

Thank you for all help. I added servervariables like remote_host, auth_user.
the remote_host display ip and auth_user display nothing even we have
internal DNS and IIS logging is enabled. I also read an article from MS, I
need to work on the intranet and it may increase the traffic. I haven't try
it.

Networking, Internet, Routing, VPN, Anti-Virus, Tips & Troubleshooting on
http://www.ChicagoTech.net
This posting is provided "AS IS" with no warranties.
 
J

Jeff Cochran

I would like to display the hostname (or computername) and username (or
logonID) on our Intranet support page. I saved the following vbs code as asp
file, but it doesn't display the username. No error also. Do I miss some
thing?

dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
strUserDomain = objNetwork.UserDomain
Wscript.Echo "User " & objNetwork.UserName

Well, you missed that this isn't VBScript... :)

This is WSH, and won't work in a web page as you intend. There are a
few ways around this. If you're using Windows authentication in your
intranet site (not just anonymous access) you can use the server
variables. Something like:

User = Request.ServerVariables("Logon_User")
Response.Write User

Alternatively, you can capture WshNetwork properties such as
UserDomain and UserName in a login script, then save them to a text
file, database or whatever. We do a bit of both, capturing
information in a logon script to a database and using it from intranet
pages as needed.

Jeff
 
B

Bob Lin

Hi Jeff,

Thank you. Will try this and let you know.

--
For more and other information, go to http://www.ChicagoTech.net

Don't send e-mail or reply to me except you need consulting services.
Posting on MS newsgroup will benefit all readers and you may get more help.

Robert Lin, MS-MVP, MCSE & CNE
Networking, Internet, Routing, VPN, Anti-Virus, Tips & Troubleshooting on
http://www.ChicagoTech.net
This posting is provided "AS IS" with no warranties.
 
B

Bob Lin

Hi Ray,

Thank you again. Will try this and let you know.
..

Robert Lin, MS-MVP, MCSE & CNE
Networking, Internet, Routing, VPN, Anti-Virus, Tips & Troubleshooting on
http://www.ChicagoTech.net
This posting is provided "AS IS" with no warranties.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top