dcolumbus
dcolumbus

Reputation: 9722

ASP.NET MVC 2: Authentication with custom SQL Database?

I'm looking into how to integrate [Authorize] within my MVC 2 application... I'm reading articles about it and I've run the aspnet_regsql tool. I see that my database now containes a bunch of new tables and a whole hell of a lot of SPROCs.

Why is all of this necessary? I thought that I would be able to check login credentials in a table that I've already created for Party ... can't I just call a SPROC that checks the login credentials and then logs the user in? Why all of these new tables and SPROCs?

Upvotes: 0

Views: 1660

Answers (2)

Jason Goemaat
Jason Goemaat

Reputation: 29214

It sounds like you want to create a custom membership provider. For logging in I think you really only need to override the ValidateUser method: http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx

For roles you may be able to get by with overriding only the IsUserInRole method: http://msdn.microsoft.com/en-us/library/8fw7xh74.aspx

Upvotes: 1

angularconsulting.au
angularconsulting.au

Reputation: 28279

Because it is the way how it is works. If you using ASP.NET Membership by default you need to have database aspnetdb with lots of tables and stored procs. If you want you may customize that. In order to do that you need to implement custom membership provider.

The simple example how to do that you may find here http://msdn.microsoft.com/en-us/library/aa479048.aspx and here http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider also source code available.

Upvotes: 1

Related Questions