Hi group,
I'm trying to use CAS in my project these days. And I find a problem, for
example:
[PrincipalPermission(SecurityAction.Demand,Role="Xx x")]
static void Exec()
{}
Then the caller of this method should be a member of role "Xxx". If I define
the method like this:
[PrincipalPermission(SecurityAction.Demand,Role="Xx x")]
[PrincipalPermission(SecurityAction.Demand,Role="Yy y")]
static void Exec()
{}
Then the caller should be a member of role "Xxx", or "Yyy". My question is,
how to define the PrincipalPermissionAttribute, and it needs both "Xxx" role
and "Yyy" role.
I've tried to define like this:
[PrincipalPermission(SecurityAction.Demand,Role="Xx x,Yyy")]
but failed.
Is it possible in CAS?
Thanks,
Sunmast 4 6315
Xia Wei wrote: [PrincipalPermission(SecurityAction.Demand,Role="Xx x")] [PrincipalPermission(SecurityAction.Demand,Role="Yy y")] static void Exec() {}
Then the caller should be a member of role "Xxx", or "Yyy". My
question is, how to define the PrincipalPermissionAttribute, and it needs both
"Xxx" role and "Yyy" role.
Are you sure? The above code looks like it should require the user to
have both roles.
The PrincipalPermissionAttribute has no mechanism for specifying membership
in one of several roles. This can, however, be done using an imperative
demand as shown in the example at http://msdn.microsoft.com/library/en...ClassTopic.asp.
If you want to use declarative security to specify the principal permission,
you could use a PermissionSetAttribute with an XML representation of your
unioned PrincipalPermission. e.g. (watch out for wrapping):
[PermissionSet(SecurityAction.Demand, XML = "<PermissionSet><Permission
class=\"System.Security.Permissions.PrincipalPermi ssion, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"
version=\"1\"><Identity Authenticated=\"true\" Role=\"Xxx\"/><Identity
Authenticated=\"true\" Role=\"Yyy\"/></Permission></PermissionSet>")]
static void Exec()
{}
HTH,
Nicole
"Xia Wei" <ip*****@gmail.com> wrote in message
news:d2***********@mail.cn99.com... Hi group,
I'm trying to use CAS in my project these days. And I find a problem, for example:
[PrincipalPermission(SecurityAction.Demand,Role="Xx x")] static void Exec() {}
Then the caller of this method should be a member of role "Xxx". If I define the method like this:
[PrincipalPermission(SecurityAction.Demand,Role="Xx x")] [PrincipalPermission(SecurityAction.Demand,Role="Yy y")] static void Exec() {}
Then the caller should be a member of role "Xxx", or "Yyy". My question is, how to define the PrincipalPermissionAttribute, and it needs both "Xxx" role and "Yyy" role.
I've tried to define like this: [PrincipalPermission(SecurityAction.Demand,Role="Xx x,Yyy")]
but failed. Is it possible in CAS?
Thanks, Sunmast
Hi, thanks for your advice!
But it seems a bit complicated...
Now I think the FCL's developers didn't had a think about this requirement?
Or they didn't recommand to do this...
Thanks,
Sunmast
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... The PrincipalPermissionAttribute has no mechanism for specifying membership in one of several roles. This can, however, be done using an imperative demand as shown in the example at http://msdn.microsoft.com/library/en...ClassTopic.asp.
If you want to use declarative security to specify the principal permission, you could use a PermissionSetAttribute with an XML representation of your unioned PrincipalPermission. e.g. (watch out for wrapping):
[PermissionSet(SecurityAction.Demand, XML = "<PermissionSet><Permission class=\"System.Security.Permissions.PrincipalPermi ssion, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" version=\"1\"><Identity Authenticated=\"true\" Role=\"Xxx\"/><Identity Authenticated=\"true\" Role=\"Yyy\"/></Permission></PermissionSet>")] static void Exec() {}
HTH, Nicole
"Xia Wei" <ip*****@gmail.com> wrote in message
news:d2***********@mail.cn99.com... Hi, thanks for your advice!
But it seems a bit complicated... Now I think the FCL's developers didn't had a think about this requirement?
It is a very common requirement, and I have no idea why the designers chose
not to support it directly via PrincipalPermissionAttribute. You could, if
you wish, author your own attribute that does support multiple roles.
However, custom permissions attributes are ignored completely unless their
assemblies are properly registered on the machine on which the code is
executing, so this may not be a useful approach in your case.
Or they didn't recommand to do this...
No idea. If the scenario is seen as common enough to merit coverage in the
code example for PrincipalPermission, it seems reasonable to expect
documentation of a declarative approach. If you feel strongly about it, you
may wish to submit a suggestion at http://lab.msdn.microsoft.com/produc...k/default.aspx for version 2.0
of the .NET Framework. Thanks, Sunmast
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... The PrincipalPermissionAttribute has no mechanism for specifying membership in one of several roles. This can, however, be done using an imperative demand as shown in the example at http://msdn.microsoft.com/library/en...ClassTopic.asp.
If you want to use declarative security to specify the principal permission, you could use a PermissionSetAttribute with an XML representation of your unioned PrincipalPermission. e.g. (watch out for wrapping):
[PermissionSet(SecurityAction.Demand, XML = "<PermissionSet><Permission class=\"System.Security.Permissions.PrincipalPermi ssion, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" version=\"1\"><Identity Authenticated=\"true\" Role=\"Xxx\"/><Identity Authenticated=\"true\" Role=\"Yyy\"/></Permission></PermissionSet>")] static void Exec() {}
HTH, Nicole
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Darren Dale |
last post by:
Hello,
def test(data):
i = ? This is the line I have trouble with
if i==1: return data
else: return data
a,b,c,d = test()
|
by: Sans Spam |
last post by:
Greetings! I have a table that contains all of the function
permissions within a given application. These functions are different
sections of a site and each has its own permissions (READ, WRITE,...
|
by: AGoodSpellr |
last post by:
Is it possible to use Visual Studio to create ASP.NET projects on a web
server, without giving the various people that will be doing this full
administrator privliges? Each user will need to have...
|
by: Kristen |
last post by:
Hi, I'm not sure if this can be done or not but here goes...
I write an application that uses Access and an MDW file to control who
can open the database. Right now I have a bunch of different...
|
by: Brian Farnhill (MCP VB.NET) |
last post by:
Hi,
I am having some trouble using the MailMessage object to send an email with
more than one attachment.
I am working on a web based application where a user can submit information,
along...
|
by: Carl Griffin |
last post by:
I am working an an application to enumerate users and permissions
they have to read certain fax queues on a fax server. The problem I am
having is that I can't figure out a way to let the admin...
|
by: Allen Browne |
last post by:
If you develop for others, you probably have multiple versions of Access
installed so you can edit and create MDEs for clients in different versions.
This works fine under Windows XP, even with...
|
by: sangam56 |
last post by:
Hello!I am using following sql statement:
SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE
Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE
Permissions.RoleID=(SELECT Roles.RoleID...
|
by: themastertaylor |
last post by:
I have developed a database, split it, loaded the back end onto a
shared folder on the network and placed a copy of the front end on
each user's pc. the database is set to open in shared mode,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |