zoukankan
html css js c++ java
基于角色的代码权限
基于角色的代码权限
演示了.NET中基于角色的安全控制,并且演示了安全控制中,对应用程序域的初始化步骤。
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Drawing;
using
System.Windows.Forms;
public
class
WindowsForm : System.Windows.Forms.Form
{
public
static
void
Main()
{
AppDomain currentDomain
=
AppDomain.CurrentDomain;
currentDomain.SetPrincipalPolicy(
System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
Application.Run(
new
WindowsForm());
}
private
Button btnOp1, btnOp2;
public
WindowsForm()
{
btnOp1
=
new
Button();
btnOp1.Text
=
"
操作A(本操作对角色无要求)
"
;
btnOp1.Size
=
new
Size(
300
,
23
);
btnOp1.Location
=
new
Point(
10
,
20
);
btnOp1.Click
+=
new
EventHandler(OnOperation1);
this
.Controls.Add(btnOp1);
btnOp2
=
new
Button();
btnOp2.Text
=
"
操作B(本操作要求本机管理员权限)
"
;
btnOp2.Size
=
new
Size(
300
,
23
);
btnOp2.Location
=
new
Point(
10
,
60
);
btnOp2.Click
+=
new
EventHandler(OnOperation2);
this
.Controls.Add(btnOp2);
this
.Size
=
new
Size(
360
,
180
);
}
private
void
OnOperation1(
object
sender, EventArgs e)
{
MessageBox.Show(
"
操作A
"
);
}
[System.Security.Permissions.PrincipalPermission(
System.Security.Permissions.SecurityAction.Demand,
Role
=
"
Administrators
"
)]
private
void
OnOperation2(
object
sender, EventArgs e)
{
MessageBox.Show(
"
操作B
"
);
}
}
查看全文
相关阅读:
Mysql任务调度
使用 IntraWeb (18)
使用 IntraWeb (17)
替盛大代发的招聘启示
使用 IntraWeb (16)
使用 IntraWeb (15)
使用 IntraWeb (14)
使用 IntraWeb (13)
使用 IntraWeb (12)
使用 IntraWeb (11)
原文地址:https://www.cnblogs.com/hcfalan/p/504816.html
最新文章
C#开发Windows服务详细流程
git clone和git pull的区别
git fetch & pull详解
用一个bat文件调用另外两个bat文件,当1.bat执行完后再执行2.bat
bat 批处理切换到当前脚本所在文件夹
集中式VS分布式
Git(工作区和暂存区概念)
图解Git
mp4文件格式解析二
MP4文件格式解析
热门文章
通过窗口句柄获取窗口消息
那些年我们遇到的坑(3)-basePackages和scanBasePackages
关于spring-boot中的@SpringBootApplication中的@ComponentScan的basePackages的路劲的设置。
Java 8 Stream 的终极技巧——Collectors 操作
解决mybatis-generator生成的Mapper文件中没有Selective结尾的方法
mybatis动态sql selective不传条件 where多余报错
FastJson配置全局LocalDateTime序列化
fastjson反序列化LocalDateTime失败的问题java.time.format.DateTimeParseException: Text '2019-05-24 13:52:11' could not be parsed at index 10
从Eclipse转移到IntelliJ IDEA一点心得
IDEA复制多行及对多行代码上下左右移动
Copyright © 2011-2022 走看看