How to check in C # if it works as a local administrator

Possible duplicate:
How do I know if my process works as an "Administrator"?

How can I test C # usage if my process is running as a local administrator?

I know how to find out if the current user is a member of the Administrators built-in group. But that is not what I want to know. I want to know if the current user is a (separate) special local administrator account.

I also know how to get the name of the current user, but I do not want to compare it with the hard-coded name "Administrator" because it will not work with localized versions of Windows (for example, "Administrador" in Spanish, "Administrator" in French and etc.).

+5
source share
1 answer

so i use

    WindowsIdentity user = WindowsIdentity.GetCurrent();
    WindowsPrincipal principal = new WindowsPrincipal(user);
    bool isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
+1
source

All Articles