473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to protect a class with a principalpermissionattribute?

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/micro...1879dbbf09528d

Mar 26 '07 #1
3 1655
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...@yahoo.comwrote:
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/micro...languages.vb/b...

Mar 27 '07 #2
thanks but msdn says you can protect a class (but i havent got the
example to work for me) and gives this example
<PrincipalPermissionAttribute(SecurityAction.Deman d, _
Name := "Bob", Role := "Supervisor")Public Class SampleClass

my question is when protecting a class, where do you put the call to
system.appdomain.currentdomain.setprincipalpolicy ?

is there an attribute that does this for assemblyinfo.vb?

thx

Mar 27 '07 #3
any ideas on this?

thx

Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: YK | last post by:
All, What is the best way to protect IL code? --------------------------------------------------- Typical scenario: Visual Studio .NET 2003 includes Dotfuscator Community Edition, which...
4
by: Cablito | last post by:
Is there a way to protect my class libraries? I have for instance, a class library full of my base forms and classes latter inherited by various projects. A lot of logic is within those...
15
by: Fady Anwar | last post by:
Hi while browsing the net i noticed that there is sites publishing some software that claim that it can decompile .net applications i didn't bleave it in fact but after trying it i was surprised...
9
by: Oriane | last post by:
Hi, I'm currently a method attribute which is used to check the "validity" of this method against a rule. I wrote the isValid method, to be used inside the otriginal method: For instance: //...
2
by: Shelby | last post by:
Hi how can I use FormsAuthentication.HashPasswordForStoringInConfigFile Method in my vb.net application I would like to achieve the same PHP crypt() function for encrypting password. However I've...
1
by: robert d via AccessMonster.com | last post by:
I don't even know if I'm able to describe what I need in the correct jargon, so please bear with me. A potential client likes my application for three out of four tasks they need done. The other...
8
by: Bill | last post by:
Anyone have any success in using global.asax to protect images in a folder from being linked to by external websites? I'd tried to use global.asa in the past, with no success. Any help would be...
12
by: =?Utf-8?B?am9uaWdy?= | last post by:
I wrote a simple VB.NET application that imports and edits CSV files. Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be opened separately. It is not high-sensitive...
22
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.