C# 声明基于角色的安全性
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Exam2
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
try
{
ShowMessage();
}
catch (SecurityException exception)
{
Console.WriteLine("Security exception caught ({0})", exception.Message);
Console.WriteLine("The current principal must be in the local"
+ "Users group");
}
Console.Read();
}
//[PrincipalPermission(SecurityAction.Demand, Role = "BUILTIN\\Users")]
[PrincipalPermission(SecurityAction.Demand, Role = "BUILTIN\\Guest")]
static void ShowMessage()
{
Console.WriteLine("The current principal is logged in locally ");
Console.WriteLine("(member of the local Users group)");
}
}
}
最新文章
- 【2016-10-16】【坚持学习】【Day7】【建造者模式】
- MVC中使用EF的技巧集
- AngularJS之directive
- Gated Recurrent Unit (GRU)公式简介
- iTunes访问自己应用的沙盒
- jdbc调用sparksql
- 实际例子描述和分析“猎豹抢票跨站推荐功能有票刷不到”的疑似bug
- netstat详解
- WebSocket协议
- UEFI模式下安装Win 7系统
- Android 6.0 以及HttpClient
- maven 编
- Telegram学习解析系列(二):这我怎么给后台传输数据?
- [ZJOI2007] 捉迷藏
- 题解:YNOI/GZOI2019 与或和
- sqlite3如何判断一个表是否已经存在于数据库中 C++
- 一条sql解决.一张表的数据复制到另外一张表
- mui 页面提示:Unable to preventDefault inside passive
- mysql 语句 GROUP_CONCAT
- 基于FPGA摄像头图像采集显示系统
热门文章
- Android 升级到Android Studio2.2 后打不开以前版本的项目
- php输出文件,数组
- xp2p系统的10点技术创新和经验总结
- 一步步学习Linux多任务编程
- oracle改动登录认证方式
- Linux下iptables屏蔽IP和端口号
- [Angular] Export directive functionalities by using 'exportAs'
- 【codeforces 546B】Soldier and Badges
- NOIP模拟 poke - 贪心
- WPF入门(三)->;几何图形之线条(LineGeometry)