Created
July 5, 2021 13:21
-
-
Save nataz77/58dbff4f1088378cc3a32cb5945a9758 to your computer and use it in GitHub Desktop.
Check if user is admin/su
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
//Install Mono.Posix.NETStandard | |
public static bool IsAdministrator => | |
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? | |
new WindowsPrincipal(WindowsIdentity.GetCurrent()) | |
.IsInRole(WindowsBuiltInRole.Administrator) : | |
Mono.Unix.Native.Syscall.geteuid() == 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment