How to find if a user is administrator or not
It’s quite common to find out whether a user or application is running Admin account or not.
well I’ve already posted a article entitled “Run Application Only in Administrator Account”. Have a look there
In addition to the above reference, you can use the given code also to find out whether the user is Admin or not. Just use
public static bool IsAdmin()
bool isAllowed = false;
using (PrincipalContext pc = new PrincipalContext(ContextType.Machine, null))
UserPrincipal up = UserPrincipal.Current;
GroupPrincipal gp = GroupPrincipal.FindByIdentity(pc, "Administrators");
isAllowed = true;
In addition we can also some other way if we are using Visual Studio 2010 by adding an application manifest file. In you’re using VS 2010, there’s an option for one in the “Add New Item” dialog (right click on the project, click “Add” then click “New Item”) and then we need to edit the generated file to uncomment the line that says:[sourcecode language=”csharp”] <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
The above procedure will not only forces the UAC dialog to open when you run the application, it also puts a little shield over your icon (well, in Windows 7 anyway).
You can find more details from there-MSDN[Create and Embed an Application Manifest (UAC)]
In addition I’ve posted similar tips at some different community forum. Have a look there
DotNetFunda[Run application only in Admin account]
AlternateTip-[How to find if a user is administrator or not]