Help with Role Based Security.
- by Bill K
Hello,
I'm trying to understand role based security and I have the following method:
[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
static void Test()
{
//administratos only can call this code
}
What I wanna do is that only users that are members of the Windows Administrators group can call this code, however, if I do the following, it works:
GenericIdentity genericIdentity = new GenericIdentity("test", "test");
GenericPrincipal genericPrincipal = new GenericPrincipal(genericIdentity, new string[] { "Administrators" });
AppDomain.CurrentDomain.SetThreadPrincipal(genericPrincipal);
Test();
So, how can I make it work only if the user is in the Administrators windows group?
thanks!