Last active
March 15, 2022 20:52
-
-
Save matterpreter/645e212f6ddde040820de874170472fd to your computer and use it in GitHub Desktop.
Check if user is a member of the local admins group
This file contains 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
public static bool IsAdmin() | |
{ | |
WindowsIdentity identity = WindowsIdentity.GetCurrent(); | |
WindowsPrincipal principal = new WindowsPrincipal(identity); | |
if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) | |
{ | |
return false; | |
} | |
else | |
{ | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment