• 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();
            }
        }
    }
  • 相关阅读:
    编译原理笔记 2
    编译原理笔记 1
    初步学习计算机图形学 [闫令琪]
    复杂 Web 前端的设计
    使用 GitHub Actions 部署 .Net 5 程序
    ES 2020 Optional Chain (可选链)
    2020 Web 前端学习记录
    WPF TreeView 支持多选
    linux (CentOS 7)报错:yum 命令报错 “ Cannot find a valid baseurl for repo: base/7/x86_6 ”
    node.js 报错
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434773.html
Copyright © 2020-2023  润新知