1

I have an ASP.NET MVC3 project and I need to implement authentification for this one.

To authenticate the user, I want to use forms authentication with an existing user table which stores username/password. After that, with GlobalActionFilterAttribute, I would check if user has access to data he wants.

So, how can i easily implement forms authentication with personnal tables ?

Thanks in advance.

Nick Larsen
  • 18,631
  • 6
  • 67
  • 96
eka808
  • 2,257
  • 3
  • 29
  • 41

2 Answers2

5

You could do this other ways, but I would look at writing a MembershipProvider (and RoleProvider, if necessary), that uses your existing tables as the authorization store. Plug these into your web.config and you can use the existing AuthorizeAttribute and login code provided in template solution. Don't be intimidated by the signature on the MembershipProvider. The methods are typically easy to write and if you don't actually use them, you can leave them unimplemented.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
  • +1 as well. The MSDN docs may be a bit verbose, but it is pretty straight forward. Look @ the default MVC project that gets created in visual studio and it'll get you started. The `Account` model should have what you need. – TheRightChoyce Jan 27 '11 at 16:32
0

I provided this answer some time ago, maybe you can find it useful.

You may also find this other post useful for implementing your custom authentication method.

Community
  • 1
  • 1
uvita
  • 4,124
  • 1
  • 27
  • 23