Reputation: 220
I'm trying to implement auto authentication in an asp portal which will be used in an intranet only. I want to allow only specific users to use that and want to authenticate them using their NT logins of Active Directory. Using the following code to get the user id but it is gives null.
String sUser = Request.ServerVariables["LOGON_USER"].ToLower();
Help will be highly appreciated.
Upvotes: 1
Views: 372
Reputation: 9752
Before you can access the LOGON_USER variable you must make sure the user is in fact logged in - that variable is not present when using anonymous auth.
In your web.config change the auth mode to
<authentication mode="Forms" />
Windows is also a valid alternative for Forms if you wish to use it.
Have a look here for more info
Upvotes: 1