If you have disabled Anonymous access, then you should be able to retrieve the value from:
<% Response.Write Request.ServerVariables("LOGON_USER") ' or Response.Write Request.ServerVariables("AUTH_USER") %> |
Note that your users must be using Internet Explorer to support NT Challenge/Response (IIS 4.0) or Windows Authentication (IIS 5.0+).
If you need to support Netscape as well, then you can access these variables by enabling Basic Authentication as well as Windows Authentication. Note that this method of authentication is slightly less secure, since the password is sent in plain text (with Windows Authentication, IE encrypts the password as it is being sent across).
If you can't disable Anonymous access, then there is a possible alternative, provided you're not using DHCP. If your users have static IP addresses, you could store their usernames in a table and do a lookup against their IP:
<% Response.Write Request.ServerVariables("REMOTE_ADDR") %> |
If you can't enforce either of those things, then you may have to resort to forcing your users to log in (even only once, then storing a cookie). I suppose this depends on balancing the importance of knowing who is on the site versus every user having to log in.