31

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.

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?

I have very little experience with ASP.Net's role management. Can someone point me in the right direction or at some good literature.

uriDium
  • 13,110
  • 20
  • 78
  • 138

2 Answers2

75

you can add the PrinicpalPermission attribute multiple times.

[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
[PrincipalPermission(SecurityAction.Demand, Role="AnotherRole")]
Kieron
  • 26,748
  • 16
  • 78
  • 122
-2
[PrincipalPermission(SecurityAction.Demand, Role="Admin,Another RoleName")]
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
JOHN
  • 19
  • 1