It's quite common to find out whether a user or application is running Admin account or not.
CodeProject already has excellent tips focusing a nice way to accomplish the same task.
Have a look at the CodeProject links.
Tips posted by John
Is Your App Running As Administrator?[
^] and Sam Cragg gives an excellent alternate tip to John's tip.
Sam tries to focus on how to use the application manifest file (It works only in VS2010).
<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />
Alternate Tip Link:
Is Your App Running As Administrator?(AlternateTip By Cragg)[
^]
Reference Link:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[
^]
In addition, I've also posted my code in another forum which focuses on the same concept.
Admin Check[
^]
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
System.DirectoryServices.AccountManagement
:
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");
if (up.IsMemberOf(gp))
isAllowed = true;
}
return isAllowed;
}
Reference Link:
MSDN-[System.DirectoryServices.AccountManagement][
^]
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.