I have a Delete method in all my business objects that has the PrincipalPermission attribute on it.
Example:
[PrincipalPermission(SecurityAction.Demand, Role = "Vendor Manager")] public static bool Delete(Vendor myVendor) {
The problem is that it seems to completely ignore my PrincipalPermission. It allows anyone, no matter what role they can be part of.
Is there anything else I forgot to do? I added the following to my global.asax application under the "Launch Application" section:
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
But this also does not matter.
I also tried the following:
public static bool Delete(Vendor myVendor) { PrincipalPermission iPerm = new PrincipalPermission(null, "Vendor Manager"); iPerm.Demand();
and I donβt know, it works great! ... any ideas on why it works in one way, but not in another?
source share