Reputation: 1225
I have two questions concerning authentication of a intranet website and how to go about doing it.
Upvotes: 4
Views: 2499
Reputation: 1225
Thanks for all the great input. They got me going in the right direction and then the customer decided to change direction. They want to have it auto login if they are in the right group, otherwise display and error message. The Form authentication would have worked as described.
Upvotes: 0
Reputation: 4081
Use forms authentication instead of windows authentication. Have a look on these link they provide walk throughs for using forms authentication :
http://www.asp.net/web-forms/tutorials/security/introduction/an-overview-of-forms-authentication-vb
http://www.dotnetfunda.com/articles/article141.aspx
For using active directory go through these links :
http://msdn.microsoft.com/en-us/library/ms180890(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/ff650308.aspx
Upvotes: 1
Reputation: 7259
In your web.config file you need to add the following
<authentication mode="Forms">
<forms loginUrl="YOUR LOGIN PAGE!!" timeout="2880" />
</authentication>
in the <system.web />
tag.
That will force the user to authenticate for that site.
The [Authorize]
attribute is used to require a user be authenticated (like you had put in your question), BUT!! only for MVC applications http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx
With MVC you can also do the [RequiresAuthentication(Roles = "admin")]
attribute which will give you control over which rolls have access to which endpoints.
I would seriously consider MVC
Upvotes: 2
Reputation: 2311
Here's a guide to setting up Forms Authentication on your site: https://web.archive.org/web/20211020150650/http://www.4guysfromrolla.com/webtech/110701-1.shtml
Part 2 has the meat of the stuff.
Upvotes: 1