Created
February 24, 2012 06:06
-
-
Save lmatt-bit/1898235 to your computer and use it in GitHub Desktop.
判断是否为管理员
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Security.Principal | |
| public static bool IsAdministrator() | |
| { | |
| WindowsIdentity identity = WindowsIdentity.GetCurrent(); | |
| WindowsPrincipal principal = new WindowsPrincipal(identity); | |
| return principal.IsInRole(WindowsBuiltInRole.Administrator); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment