Possible Duplicate:
How can I tell if my process is running As Administrator?
How can I check using C# if my process is running as the local Administrator?
I know how to find out if the current user is a member of the builtin Administrators group. But this is not what I want to know. I want to know if the current user is the (one-and-only) special local Administrator account.
I do also know how to retrieve the name of the current user, but I do not want to compare that to the hardcoded name "Administrator" because this will not work with localized versions of Windows (e. g. "Administrador" in Spanish, "Administrateur" in French etc.).
this is the way i use
WindowsIdentity user = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(user);
bool isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With