title: Role Based Security in the Administrators windows group
body: <p>I'm trying to understand role based security and I have the following method:</p>
  
  <pre><code>[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
  static void Test()
  {
      //administratos only can call this code
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>GenericIdentity genericIdentity = new GenericIdentity("test", "test");
  GenericPrincipal genericPrincipal = new GenericPrincipal(genericIdentity, new string[] { "Administrators" });
  AppDomain.CurrentDomain.SetThreadPrincipal(genericPrincipal);
  
  Test();
  </code></pre>
  
  <p>So, how can I make it work only if the user is in the Administrators windows group?</p>
  
  <p>thanks!</p>