zoukankan      html  css  js  c++  java
  • C# WindowsPrincipal(Windows规则)的使用

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Principal;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;


    namespace WindowsPrincipal
    {
        class Program
        {
            static void Main(string[] args)
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);


                System.Security.Principal.WindowsPrincipal principal = (System.Security.Principal.WindowsPrincipal)Thread.CurrentPrincipal;
                WindowsIdentity identity = (WindowsIdentity)principal.Identity;
                Console.WriteLine("IdentityType: " + identity.ToString());
                Console.WriteLine("Name: {0}", identity.Name);
                Console.WriteLine("‘Users’?: {0} ", principal.IsInRole(WindowsBuiltInRole.User));
                Console.WriteLine("‘Administrators’? {0}", principal.IsInRole(WindowsBuiltInRole.Administrator));
                Console.WriteLine("Authenticated: {0}", identity.IsAuthenticated);
                Console.WriteLine("AuthType: {0}", identity.AuthenticationType);
                Console.WriteLine("Anonymous? {0}", identity.IsAnonymous);
                Console.WriteLine("Token: {0}", identity.Token);


                Console.Read();
            }
        }
    }
  • 相关阅读:
    测试次数--蓝桥杯
    承压计算--蓝桥杯
    天梯赛--连续因子
    等差素数数列-蓝桥杯
    hdu-1237-简单计算器
    hdu-1022-栈
    [BZOJ3172]:[Tjoi2013]单词(AC自动机)
    [BZOJ4327]:[JZOI2012]玄武密码(AC自动机)
    [HDU5360]:Gorgeous Sequence(小清新线段树)
    [BZOJ3307]:雨天的尾巴(LCA+树上差分+权值线段树)
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434773.html
Copyright © 2011-2022 走看看