I have created my own Role Provider because I found the one that ASP.Net provides to be way too bulky in terms of tables in the database. I found implementing a custom RoleProvider to be quite easy.
我创建了自己的角色提供程序,因为我发现ASP.Net提供的数据库中的表格过于庞大。我发现实现自定义RoleProvider非常简单。
My only problem is that right now I cannot have multiple roles for a page. I saw somewhere that at the top of your class you need to "anotate it" with some security code. This is what I have
我唯一的问题是,现在我不能拥有一个页面的多个角色。我在某个地方看到你需要用一些安全代码来“激活它”。这就是我所拥有的
[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
If I try to include multiple roles by using a comma separated list I get errors. If i try to specify multiple role keys then I also get errors. Do i Need to specify multiple PrinicipalPermissions by any chance?
如果我尝试使用逗号分隔列表包含多个角色,我会收到错误。如果我尝试指定多个角色键,那么我也会遇到错误。我是否需要指定多个PrinicipalPermissions?
I have very little experience with ASP.Net's role management. Can someone point me in the right direction or at some good literature.
我对ASP.Net的角色管理经验很少。有人能指出我正确的方向或一些好的文献。
2 个解决方案
#1
69
you can add the PrinicpalPermission attribute multiple times.
您可以多次添加PrinicpalPermission属性。
[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
[PrincipalPermission(SecurityAction.Demand, Role="AnotherRole")]
#2
-3
[PrincipalPermission(SecurityAction.Demand, Role="Admin,Another RoleName")]
#1
69
you can add the PrinicpalPermission attribute multiple times.
您可以多次添加PrinicpalPermission属性。
[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
[PrincipalPermission(SecurityAction.Demand, Role="AnotherRole")]
#2
-3
[PrincipalPermission(SecurityAction.Demand, Role="Admin,Another RoleName")]