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!

Getting the NT Logon from the browser

ASP-Enabled Web Server

Getting the NT Logon from the browser

by  jfriestman  Posted    (Edited  )
Step 1: Set up the proper authentication on the Webserver. Don't try to do this with Anonymous Access.

With either IIS or PWS, Right click on the folder or website, choose properties, choose directory security, choose edit, choose Windows NT Challenge Response (for IE) and Basic Authentication (for Netscape). NOTE: there are security issues with using Basic Authentication. Please consult the IIS documentation for more information.

Step 2: Use this function.

Function NTUserName()
'declare variables
Dim logon, myArray

'will return Domain\Username or just Username depending
'if the user is logged into the domain or their local machine.
'also browser dependent. go figure.
logon = Request.ServerVariables("LOGON_USER")

'so we split the logon variable by the "\"
myArray = Split(logon, "\", -1, 1)

'take the upper bound of the logon variable
logon = myArray(Ubound(myarray))

'and you're left with just the NT Username
NTUserName = logon

End Function


If you get an Array out of bounds error, check the authentication on the webserver... I bet you don't have the authentication set up properly.

Happy programming
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top