How To let all users in a Group to call a method by using an attribute?

  • Thread starter Thread starter Leon_Amirreza
  • Start date Start date
L

Leon_Amirreza

I Used this and an exception is thrown:
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = @"BUILTIN\Backup
Operators")]
 
Well, by default, .NET sets the principal of an application to a
GenericPrincipal instance, which has no knowledge of the current
identity/user.

If you want the windows principal to be used across the app domain, then
you need to call the SetPrincipalPolicy on the app domain, passing the
WindowsPrincipal value from the PrincipalPolicy enumeration:

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

This will cause the principal on new threads to be a WindowsPrincipal
instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top