惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 源码工作室

什么是公司战略 开通了知识星球圈“程序猿团队管理之道” 我们的双12活动总结 做电商的切身经验分享 Android编译报Errors running builder 'Android Pre Compiler' on project 'XXX' java.lang.NullPointerException 技术不如你,但老板就是赏识他,为什么? 看我是如何快速学习android开发的(一) 屌丝创业,你能闯过这么多关吗? android不能显示log的问题 第一次和风投接触 你体会过创业的艰辛吗? 多个WPF工程公用ResourceDictionary文件 Bambook大赛程序结果发布兼拉票 Bambook大赛程序终于发布了 删除USB转串口的所有驱动 《家庭财务总管》升级(1.0.0.3) MFC中Wizard中看不到类的解决办法 总结C++中的所有强制转换函数(const_cast,reinterpret_cast,static_cast,dynamic_cast)(转载) WPF中template的区别
C# 如何检查当前用户在Windows系统下的权限
源码工作室 · 2010-02-10 · via 博客园 - 源码工作室

Posted on 2010-02-10 11:35  源码工作室  阅读(2459)  评论()    收藏  举报

System.Security.Principal.WindowsIdentity wid = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal printcipal = new System.Security.Principal.WindowsPrincipal(wid);
bool isAdmin=(printcipal .IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator));
如果 isAdmin 为true,则是在管理员权限下。

namespace System.Security.Principal
{
    // Summary:
    //     Specifies common roles to be used with System.Security.Principal.WindowsPrincipal.IsInRole(System.String).
    [Serializable]
    [ComVisible(true)]
    public enum WindowsBuiltInRole
    {
        // Summary:
        //     Administrators have complete and unrestricted access to the computer or domain.
        Administrator = 544,
        //
        // Summary:
        //     Users are prevented from making accidental or intentional system-wide changes.
        //     Thus, users can run certified applications, but not most legacy applications.
        User = 545,
        //
        // Summary:
        //     Guests are more restricted than users.
        Guest = 546,
        //
        // Summary:
        //     Power users possess most administrative permissions with some restrictions.
        //     Thus, power users can run legacy applications, in addition to certified applications.
        PowerUser = 547,
        //
        // Summary:
        //     Account operators manage the user accounts on a computer or domain.
        AccountOperator = 548,
        //
        // Summary:
        //     System operators manage a particular computer.
        SystemOperator = 549,
        //
        // Summary:
        //     Print operators can take control of a printer.
        PrintOperator = 550,
        //
        // Summary:
        //     Backup operators can override security restrictions for the sole purpose
        //     of backing up or restoring files.
        BackupOperator = 551,
        //
        // Summary:
        //     Replicators support file replication in a domain.
        Replicator = 552,
    }
}