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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.