Find the user name (and domain) for logged in user for in an internal intranet site
It was an old post, but helped me even after 15 years, this is how we can find the login user (and domain) of the logged in user in an internal intranet site.
Can use some work to show an error message if user is not logged in.
CurrentAuth = Request.ServerVariables("AUTH_USER")
CurrentAuthType = Request.ServerVariables("AUTH_TYPE")
CurrentAuthUser = ""
CurrentAuthDomain = ""
If CurrentAuth = "" Then
If UCase(Request.ServerVariables("SERVER_NAME")) = UCase("Localhost") Then
CurrentAuthUser = "ANmar Developing"
CurrentAuthDomain = "Local"
CurrentAuthUser = CutString3(CurrentAuth, 2, "\")
CurrentAuthDomain = CutString3(CurrentAuth, 1, "\")
'Force Authentication if the LOGON_USER Server Variable is blank by sending the Response.Status of 401 Access Denied.
'Finish the Page by issuing a Response.End so that a user cannot cancel through the dialog box.
If CurrentAuthUser = "" Then
Response.Status = "401 Access Denied"
<HR SIZE="1" COLOR="#000000">
You logged in as user:<B> <%= CurrentAuthUser %></B>
<P>You were authenticated using:<B> <%= CurrentAuthType %></B> authentication.</P>