ASP.NET MVC - 使用现有用户表进行表单身份验证
我有一个 ASP.NET MVC3 项目,我需要为此实现身份验证。
为了对用户进行身份验证,我想对存储用户名/密码的现有用户表使用表单身份验证。之后,使用 GlobalActionFilterAttribute,我将检查用户是否有权访问他想要的数据。
那么,如何轻松地使用个人表实现表单身份验证?
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过其他方式做到这一点,但我会考虑编写一个MembershipProvider (以及 RoleProvider,如果需要的话),它使用现有的表作为授权存储。将它们插入到您的 web.config 中,您可以使用模板解决方案中提供的现有 AuthorizeAttribute 和登录代码。不要被 MembershipProvider 上的签名吓到。这些方法通常很容易编写,如果您实际上不使用它们,则可以不实现它们。
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.
我不久前提供了这个答案,也许你会发现它很有用。
您还可能会发现这篇文章对于实施很有用您的自定义身份验证方法。
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.