INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ASP-Enabled Web Server

Getting the NT Logon from the browser by jfriestman
Posted: 19 Jul 00

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

Back to Microsoft: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close