Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Created February 24, 2012 06:06
Show Gist options
  • Select an option

  • Save lmatt-bit/1898235 to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/1898235 to your computer and use it in GitHub Desktop.
判断是否为管理员
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