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
"
);
}
}
查看全文
相关阅读:
orcal中创建和删除表空间和用户
tomcat常用的优化和配置
tomcat中如何禁止和允许主机或地址访问
velocity生成静态页面代码
java下载文件
java上传文件
数据库行列转换
JDBC连接数据库详解
java中插入myslq的datetime类型的
简单的邮件发送mail.jar
原文地址:https://www.cnblogs.com/hcfalan/p/504816.html
最新文章
配置SVN服务器
UIApplicationsharedApplication的详解
数组[0]和[firstobject]的区别
qt quick中qml编程语言
图文例解C++类的多重继承与虚拟继承
浅谈C++多态性
首页 > 所有书 > 操作系统 > Linux >
QT中文字的绘制
QT_圆_直线_三角t
qt 摄像头程序
热门文章
[宏]_IO, _IOR, _IOW, _IOWR 宏的用法与解析
S3C6410 LCD Overlay Test Program
全面的framebuffer详解
项目开发流程简述
ubuntu上安装lamp环境命令清单
php数据库应用程序建议
php的 '1' == 1, 返回true,到底是谁变成了谁?
php静态变量的运用
树的遍历
PHP获取所有扩展及扩展下的所有函数签名生成php.snippet
Copyright © 2011-2022 走看看