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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Leon_Amirreza" <amirreza_rahmaty@xxxxxxxxx> wrote in message
news:%231C5jcHxHHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
I Used this and an exception is thrown:
[PrincipalPermissionAttribute(SecurityAction.Demand, Role =
@"BUILTIN\Backup Operators")]




.