It should be noted that there was a significant change in behavior between the 1.1 and the 2.0 framework versions of the PrincipalPermissionAttribute. The change has the possibility to open security holes in existing code that is migrated from 1.1. See link
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=95127PrincipalPermissionAttributes can be applied at both the class and method level. Consider the following code of a simple class requiring either a role of "RoleOne" OR "RoleTwo" to instantiate the class. Then, the method DoSomething() requires a role of "RoleTwo".
[
PrincipalPermission(SecurityAction.Demand, Role="RoleOne"),
PrincipalPermission(SecurityAction.Demand, Role="RoleTwo")]
publicclassWidget
{
public Widget()
{
// TODO:
}
[
PrincipalPermission(SecurityAction.Demand, Role="RoleTwo")]
publicvoid DoSomething()
{
// TODO:
}
}
Now, consider a user who has ONLY "RoleOne" and NOT "RoleTwo".
In the 1.1 Framework, the user could instantiate the class because he belongs to one of the required roles. The user could NOT call DoSomething(), however because he does not have "RoleTwo".
In the 2.0 Framework, the user could instantiate the class because he belongs to one of the required roles. The user could then ALSO call DoSomething(), even though he does not have "RoleTwo" because the method attribute is not exclusive and the class attributes let in the user.
It seems to work like, "Is the user in RoleOne OR RoleTwo OR RoleTwo(from the method)". Since the user is in RoleOne, he is in. This can break existing code. Also, the developer needs to keep this in mind for future development.