title: Detect if running as Administrator with or without elevated privileges?
body: <p>I have an application that needs to detect whether or not it is running with elevated privileges or not.  I currently have code set up like this:</p>
  
  <pre><code>static bool IsAdministrator()
  {
      WindowsIdentity identity = WindowsIdentity.GetCurrent();
      WindowsPrincipal principal = new WindowsPrincipal(identity);
      return principal.IsInRole (WindowsBuiltInRole.Administrator);
  }
  </code></pre>
  
  <p>This works to detect if a user is an administrator or not, but doesn't work if running as an administrator without elevation.  (For example in vshost.exe).</p>
  
  <p>How can I determine whether or not <em>elevation is [already in force or] possible</em>?</p>