如何在 ASP.NET MVC3 中使用基于 Windows 身份验证的自定义基于角色的授权?
我正在创建一个具有 Windows 身份验证 的 ASP.NET MVC3 Intranet 应用程序。我只希望域用户使用此应用程序。一旦域用户通过身份验证(使用 Active Directory),我计划创建用户(使用 AD 用户名)、角色和角色。 SQL Server 中的 UserRoles 表用于授权。
因此,如果用户是具有某些权限集(访问控制器/操作)的角色的一部分,我应该只允许该角色中的用户执行/查看它们。
例如:如果有一个操作 /Locations/Create,则允许执行该操作的角色只能执行该操作。
有人可以给我一些指点吗?我是否应该创建自定义操作过滤器,并将过滤器属性用于我希望过滤器应用到的任何操作方法?
I'm creating an ASP.NET MVC3 intranet application with Windows authentication. I only want domain users to use this application. Once a domain user is authenticated (with Active Directory), I'm planning to create Users (with AD username), Roles & UserRoles tables in SQL Server for authorization.
So if an user is a part of a role which has some set of permissions (to access controllers/actions), I should only allow the users in that role to execute/view them.
Eg: if there is an action /Locations/Create, the roles which are allowed to perform that, can only do that.
Can somebody give me some pointers? Should I create a custom action filter, and use filter attribute to any action method that I want the filter to apply to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

示例:
请参阅此处了解更多详细信息。
请注意,使用 [Authorize] 属性需要您使用某种会员资格提供程序。
Example:
See here for more details.
Note that using the [Authorize] attribute requires you to use some sort of Membership provider.