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"
You logged in as user: <%= CurrentAuthUser %>
You were authenticated using: <%= CurrentAuthType %> authentication.