This lesson will guide you through using the static SecuritySystem class to check whether or not a user has particular permission. The SetTask Action will be accessible to users who have permission to modify DemoTask objects.

本课将指导您使用静态安全系统类检查用户是否具有特定权限。具有修改演示任务对象权限的用户可以访问 SetTask 操作。

Note 注意
Before proceeding, we recommend that you review the following lessons.
在继续之前,我们建议您复习以下课程。
  • Using the Security System
  • 使用安全系统
  • Add an Action with Option Selection
  • 添加具有选项选择的操作
  • Open the TaskActionsController.cs (TaskActionsController.vb) file you created in the Add an Action with Option Selection lesson. Add the "using" directive and modify the Activated event handler as shown below.

  • 打开您在"使用选项选择添加操作"一课中创建的TaskActionsController.cs(TaskActions控制器.vb)文件。添加"using"指令并修改激活的事件处理程序,如下所示。

using DevExpress.ExpressApp.Security;
//...
public partial class TaskActionsController : ViewController {
// ...
private void TaskActionsController_Activated(object sender, EventArgs e) {
View.SelectionChanged += new EventHandler(View_SelectionChanged);
UpdateSetTaskActionState();
}
void View_SelectionChanged(object sender, EventArgs e) {
UpdateSetTaskActionState();
}
private void UpdateSetTaskActionState() {
bool isGranted = true;
foreach(object selectedObject in View.SelectedObjects) {
bool isPriorityGranted = SecuritySystem.IsGranted(new PermissionRequest(ObjectSpace,
typeof(DemoTask), SecurityOperations.Write, selectedObject, "Priority"));
bool isStatusGranted = SecuritySystem.IsGranted(new PermissionRequest(ObjectSpace,
typeof(DemoTask), SecurityOperations.Write, selectedObject, "Status"));
if(!isPriorityGranted || !isStatusGranted) {
isGranted = false;
}
}
SetTaskAction.Enabled.SetItemValue("SecurityAllowance", isGranted);
}
}

With the added code, the Set Task Action will be activated for users who have write permissions for the Priority and Status properties of the selected DemoTask objects.

使用添加的代码,将为具有所选 DemoTask 对象的"优先级"和"状态"属性的写入权限的用户激活"设置任务操作"。

  • Add a user who does not have permission to modify the DemoTask objects (see Using the Security System). Run the application as this new user. The Set Task Action will not be visible when you display the Demo Task List View.
  • 添加无权修改"演示任务"对象的用户(请参阅使用安全系统)。以此新用户身份运行应用程序。显示演示任务列表视图时,"设置任务"操作将不可见。

This is the last lesson of the Comprehensive Tutorial. To learn more about the main concepts for building business applications and extending XAF tools, refer to the Concepts section. If you need task-based help, take a look at the Task-Based Help section. To learn how to deploy XAF applications, review the Deployment Tutorial.

这是综合教程的最后一课。要了解有关构建业务应用程序和扩展 XAF 工具的主要概念的详细信息,请参阅概念部分。如果您需要基于任务的帮助,请查看基于任务的帮助部分。要了解如何部署 XAF 应用程序,请查看部署教程。

Access the Security System in Code 在代码中访问安全系统的更多相关文章

  1. Implement Property Value Validation in Code 在代码中实现属性值验证(XPO)

    This lesson explains how to set rules for business classes and their properties. These rules are val ...

  2. Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)

    <bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...

  3. Using the Security System 使用安全系统

    In this lesson, you will learn how to use a Security System in the application. When you use this sy ...

  4. 在ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串

      1.在<connectionStrings> 标签里添加连接 <connectionStrings> <add name="ConnectionName&q ...

  5. 【Azure 云服务】在Cloud Service的代码中如何修改IIS Application Pool的配置呢? 比如IdleTimeout, startMode, Recycling.PeriodicRestart.Time等

    什么是 PaaS?Platform as a Service 平台即服务 (PaaS) 是云中的完整开发和部署环境,你可以使用其中资源交付内容,从基于云的简单应用到启用云的复杂企业应用程序皆可.你以即 ...

  6. 如何在代码中取得一个特点type的关节

    我们可以在初始化方法中添加如下代码: -(void)didLoadFromCCB{ Class distanceJointClass = NSClassFromString(@"CCPhys ...

  7. Entity Framework 5.0系列之自动生成Code First代码

    在前面的文章中我们提到Entity Framework的"Code First"模式也同样可以基于现有数据库进行开发.今天就让我们一起看一下使用Entity Framework P ...

  8. 自动生成Code First代码

    自动生成Code First代码 在前面的文章中我们提到Entity Framework的“Code First”模式也同样可以基于现有数据库进行开发.今天就让我们一起看一下使用Entity Fram ...

  9. 【转】Entity Framework 5.0系列之自动生成Code First代码

    在前面的文章中我们提到Entity Framework的“Code First”模式也同样可以基于现有数据库进行开发.今天就让我们一起看一下使用Entity Framework Power Tools ...

随机推荐

  1. java调用webservice,比较简单方便的方法。

    首先,请同学们自行了解webservice的基础知识. 个人理解,webservice约等于使用http+xml技术进行跨平台的数据交互. http和xml我们都很熟悉了,把他们两个组合到一起就是we ...

  2. 188W+程序员关注过的问题:Java到底是值传递还是引用传递?

    在逛 Stack Overflow 的时候,发现了一些访问量像阿尔卑斯山一样高的问题,比如说这个:Java 到底是值传递还是引用传递?访问量足足有 188万+,这不得了啊!说明有很多很多的程序员被这个 ...

  3. Java修炼——ArrayList常用的方法以及三种方式遍历集合元素。

    List接口ArrayList用法详解 ArrayList常用方法: 1. List.add():添加的方法(可以添加字符串,常量,以及对象) List list=new ArrayList(); l ...

  4. 数据库Oracle的select用法(部分)

    Oracle的select用法(部分): 1.查询所有: select * from employees; 2.加上where子句:用选择限制行 select * from employees whe ...

  5. 在Linux中配置jdk,Tomcat,MySQL

    解压缩: tar 命令 : 使用方式 tar [参数] source [target] source - 压缩文件 target - 解压缩后的目标位置, 默认解压到当前目录 常用写法 : 解压缩 : ...

  6. [TimLinux] JavaScript 面向对象程序设计

    1. 面向对象 面向对象语言有一个标志:都有类的概念.通过类可以创建任意多个具有相同属性和方法的对象.ECMAScript中没有类的概念,因此JavaScript中的对象夜雨基于类的语言中的面向对象有 ...

  7. AutoCAD中的螺旋究竟是什么螺旋?

    AutoCad从很早的时候就开始提供了螺旋线的功能,它的用法相对简单,非常适合用来对等距螺旋的理论进行演练. 选择螺旋线工具,首先画出一个基准圆,再向内(或向外)移动鼠标,拖出一个旋转3个周期的螺旋. ...

  8. 基于 HTML5 WebGL 构建智能数字化城市 3D 全景

    前言 自 2011 年我国城镇化率首次突破 50% 以来,<新型城镇化发展规划>将智慧城市列为我国城市发展的三大目标之一,并提出到 2020 年,建成一批特色鲜明的智慧城市.截至现今,全国 ...

  9. 十年Java程序员-带你走进Java虚拟机-类加载机制

    类的生命周期 1.加载 将.class文件从磁盘读到内存 2.连接 2.1 验证 验证字节码文件的正确性 2.2 准备 给类的静态变量分配内存,并赋予默认值 2.3 解析 类装载器装入类所引用的其它所 ...

  10. RabbitMQ之交换机及spring整合

    交换机 交换机属性: Name:交换机名称 Type:交换机类型 direct.topic.fanout.headers Durability:是否需要持久化,true为持久化 Auto Delete ...