最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)判斷當(dāng)前操作用戶管理角色的方法

 更新時(shí)間:2015年08月24日 12:46:06   作者:我心依舊  
這篇文章主要介紹了C#實(shí)現(xiàn)判斷當(dāng)前操作用戶管理角色的方法,涉及C#針對系統(tǒng)用戶判斷的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#實(shí)現(xiàn)判斷當(dāng)前操作用戶管理角色的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

/// <summary>
/// 判斷當(dāng)前操作用戶的管理角色
/// </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("當(dāng)前用戶的角色是:");
  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("系統(tǒng)管理員");
  IsUser = wp.IsInRole(System.Security.Principal.WindowsBuiltInRole.SystemOperator);
  if (IsUser)
    Console.WriteLine("系統(tǒng)操作員");
  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("復(fù)制程序員");
}

希望本文所述對大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

涞源县| 承德市| 保康县| 偏关县| 汕头市| 舞阳县| 怀远县| 东阳市| 太仓市| 商南县| 山东| 喜德县| 横峰县| 虞城县| 阿拉尔市| 青海省| 蒙城县| 龙里县| 宁波市| 西宁市| 突泉县| 寿宁县| 攀枝花市| 耿马| 绍兴市| 阳春市| 平武县| 河池市| 云龙县| 长子县| 缙云县| 汕头市| 阳春市| 淮滨县| 东阳市| 卢龙县| 磴口县| 元氏县| 永福县| 射洪县| 古田县|