PermissionTool.cs 584 B

123456789101112131415161718
  1. //############################################################
  2. // https://github.com/yuzhengyang
  3. // author:yuzhengyang
  4. //############################################################
  5. using System.Security.Principal;
  6. namespace Y.Utils.AppUtils
  7. {
  8. public class PermissionTool
  9. {
  10. public static bool IsAdministrator()
  11. {
  12. WindowsIdentity identity = WindowsIdentity.GetCurrent();
  13. WindowsPrincipal principal = new WindowsPrincipal(identity);
  14. return principal.IsInRole(WindowsBuiltInRole.Administrator);
  15. }
  16. }
  17. }