Question

I have site that has 2 pages. One page is for managers and the other is for general staff. I have a group on the server that has all the user ID's of the manager. What I want is that when the managers log on to the website, that the website picks up their user ID, compares it to the group and then redirects them to the appropriate webpage. I don't want a login page, that is what I currently have, I want the webpage to simply pick up their NT user ID and domain and then redirect based on that. No prompting for anything. Is that possible?

Was it helpful?

Solution

Yes it is you can use the Request.ServerVariables("LOGON_USER") to get the NT username.

IMPORTANT:

Make sure you have Window Authentication enabled or the value will be blank. If you're using Internet Explorer to avoid being prompted make sure the site is added to the Intranet Security Zone.

Example:

Dim ntuser
'Will contain the NT username if using Windows Authentication
ntuser = Request.ServerVariables("LOGON_USER") & ""

If Len(ntuser) > 0 Then
  'Compare ntuser against entries in database.
Else
  'Must be using Anonymous Authentication check IIS settings.
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top