首页 > 代码库 > 验证管理员权限(C#)

验证管理员权限(C#)

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
WindowsIdentity identity = (WindowsIdentity)principal.Identity;
FastPrincipal prin = new FastPrincipal(identity);	
isAdmin = prin.IsInRole(WindowsBuiltInRole.Administrator);

验证管理员权限(C#)