Skip to content Skip to sidebar Skip to footer

Mvc3 - Authenticate With Sql Server Accounts

I couldn't find anything useful to this problem and I never used authentication in a web application before. So anything with / without cookies is new for me. We've got an existing

Solution 1:

Asp.Net in general (not specific to MVC) has a builtin way to manage authentication.

It's done through MembershipProvider, RoleProvider and PrincipalProvider. You can google those for more details.

In your scenario, where you have to check user credentials against an existing schema, you could simply implement your own custom MembershipProvider (and, if needed, RoleProvider and/or PrincipalProvider) deriving from the base class.

Inside your custom provider you'll implement the signature methods with your domain specific code.

Lastly, you just register your custom provider to be the default in the web.config and you're set. Your app can use the default Membership API to authenticate users and manager credentials.

Solution 2:

If your DB structure is already decided on, you can write your own MembershipProvider that accesses your database (see http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx and http://www.codeproject.com/KB/aspnet/WSSecurityProvider.aspx).

If you are flexible on the DB structure, you can use ASP.NET's built-in SqlMembershipProvider (see http://codehighstreet.com/Articles/overview_of_membership_and_installing_sql_membership_provider-part_1/overview_of_membership_and_installing_sql_membership_provider-part_1.aspx). You then have to run a SQL script that creates the tables and indexes for you. This works in MVC 3.

Post a Comment for "Mvc3 - Authenticate With Sql Server Accounts"