PrincipalPermissionAttribute not working

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p align=left><font face=Arial size=2>This is probably really simple. Maybe Im not understanding the concept. </font>
<p align=left> 
Based on what I understand, if I am currently logged in under a user profile that requires a username and password and I am part of the Administrators group the following should work; however, when it is run under my profile which is part of "Administrators" I receive an exception stating that "Request for principle permission failed".
<p align=left> 
<p align=left>Is there something I am missing about the way PrinciplePermissions work? Any help would be appreciated - Im stumped.

<p align=left> 
<p align=left><font face="Courier New private void button1_Click(object sender, EventArgs e)
{
    try
    {
       Test(); 
    }
     catch (SecurityException ex)
    {
       MessageBox.Show(ex.Message);
    }
}

[PrincipalPermissionAttribute(SecurityAction.Demand, Role="Administrators")]
private void Test()
{
}</font>


View the full article
 
Back
Top