C#完成斷定以後操感化戶治理腳色的辦法。本站提示廣大學習愛好者:(C#完成斷定以後操感化戶治理腳色的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#完成斷定以後操感化戶治理腳色的辦法正文
本文實例講述了C#完成斷定以後操感化戶治理腳色的辦法。分享給年夜家供年夜家參考。詳細完成辦法以下:
/// <summary> /// 斷定以後操感化戶的治理腳色 /// </summary> public static void GetCurrentUserRole() { AppDomain appDomain = System.Threading.Thread.GetDomain(); appDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal); System.Security.Principal.WindowsPrincipal wp = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; bool IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.Guest); Console.Write("以後用戶的腳色是:"); if (IsUser) Console.WriteLine("賓客"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.User); if (IsUser) Console.WriteLine("通俗用戶"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.PowerUser); if (IsUser) Console.WriteLine("超等用戶"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); if (IsUser) Console.WriteLine("體系治理員"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.SystemOperator); if (IsUser) Console.WriteLine("體系操作員"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.BackupOperator); if (IsUser) Console.WriteLine("備份操作員"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.PrintOperator); if (IsUser) Console.WriteLine("打印操作員"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.AccountOperator); if (IsUser) Console.WriteLine("賬戶操作員"); IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.Replicator); if (IsUser) Console.WriteLine("復制法式員"); }
願望本文所述對年夜家的C#法式設計有所贊助。