using System.Threading;
using System.Security.Principal;
-----------------------------------------
-----------------------------------------
/// <summary>
/// 判断当前登录的用户是否属于系统管理员组
/// </summary>
/// <returns></returns>
public static bool IsAdministrator()
{
AppDomain myDomain = Thread.GetDomain();
myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
return myPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
}
using System.Security.Principal;
-----------------------------------------
-----------------------------------------
/// <summary>
/// 判断当前登录的用户是否属于系统管理员组
/// </summary>
/// <returns></returns>
public static bool IsAdministrator()
{
AppDomain myDomain = Thread.GetDomain();
myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
return myPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
}