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
"
);
}
}
查看全文
相关阅读:
分布式解决方案的收集
一天带你入门到放弃vue.js(三)
一天带你入门到放弃vue.js(二)
一天带你入门到放弃vue.js(一)
JDK配置环境变量不成功的原因
蚂蚁课堂(每特学院)-2期
Java 使用blob对H5视频播放进行加密《java视频加密》
Java 实现视频下载功能
高并发与高可用实战之基础知识大型网站架构特征(一)
Java线程池实现原理之自定义线程池(一)
原文地址:https://www.cnblogs.com/hcfalan/p/504816.html
最新文章
J2EE 的体系结构
Servlet运行原理以及生命周期
JSP与Servlet的区别
struts2的主要工作流程
Hibernate的工作流程以及三种状态
SpringMVC工作流程
Struts、Hibernate和Spring的整合
Spring框架的核心模块的作用
Spring核心--IOC&AOP
MyBatis配置文件mybatis-config.xml
热门文章
SQL查询表结构 相关语句
springboot 上传图片
swagger ui 值类型形参加文字注释
设置oracle密码不过期,修改用户密码
springboot 配置拦截器
spring boot 配置swagger UI
Oracle 已有则更新,没有则插入
springboot 使用spring security
springboot 集成oauth2
springboot 集成单元测试
Copyright © 2011-2022 走看看