Re: how to protect a class with a principalpermissionattribute?
- From: billsahiker@xxxxxxxxx
- Date: 26 Mar 2007 18:20:49 -0700
PrincipalPermissionAttribute class is used to control access to
methods, not classes, so move the attribute statement to just before
the method you want to control. You also need a
system.appdomain.currentdomain.setprincipalpolicy statement in the
constructor for the form. Then, put the call to the method in a try/
catch block to trap any exception that the runtime might throwif
there are not adequate permissions to execute the method.
On Mar 26, 8:45 am, "xamman" <xamma...@xxxxxxxxx> wrote:
hello! anyone ever manage to do this? after trying nearly everything
i
can think of my code (below) still gives 'request for principal
permissions failed' .
many thanks
x
.
.
.
.
.
Protecting to class - this doesnt work (& the tried
role:="administrators", name:="administrator" etc)
< PrincipalPermissionAttribute(SecurityAction.Demand, Role:="BUILTIN
\Administrators") _
Public Class Form1 Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal and As
System.EventArgs) Handles MyBase.Load
Messagebox("form should load if user is admin")
End Sub
if you need more details about this problem:http://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...
.
- Follow-Ups:
- References:
- Prev by Date: Re: Best ways to source controlling "Code Snippets"
- Next by Date: Re: Drilling down through directories
- Previous by thread: how to protect a class with a principalpermissionattribute?
- Next by thread: Re: how to protect a class with a principalpermissionattribute?
- Index(es):