In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to hide navigation items according to the current users in DevExpress. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Download DevExpress v20.1 full version
DevExpress technology exchange group 2RU 775869749 Welcome to join the group discussion.
DevExpress Universal Subscription has all the platform controls needed for. Net development, including more than 600 UI controls, report platform, DevExpress Dashboard eXpressApp framework, CodeRush for Visual Studio and a series of auxiliary tools.
The award-winning software development platform DevExpress Universal launched v20.1 in 2020. With many new products and dozens of high-impact features, the latest version can provide intuitive solutions for desktop, Web and mobile applications and comprehensively solve a variety of usage scenarios. Want to experience? Click download > >
System background
Platform: Frameworks (XAF & XPO)
Product: DeXpressApp Framework
Our Security System allows you to hide navigation items for certain users by configuring their navigation permissions, which can be configured in two modes.
Starting with v16.2, navigation permissions can be assigned to individual navigation projects. By default, this feature is enabled in new projects created with the wizard, and to enable it when upgrading from an older version, the SecurityStrategy.SupportNavigationPermissionsForTypes option must be set to false. If the project is based on Entity Framework, it is also necessary to update the database.
In v16.1 and earlier, navigation permissions can be assigned to specific object types through the AllowNavigate option provided in the Type Permissions settings. If the current user does not have permission to navigate to that type, all navigation items specific to the corresponding type are removed from the navigation control. This mode is enabled by default when upgrading legacy projects to v16.2 and later. To enable it in a new project created using the wizard, open the application designer and change the value of the SecurityStrategy.SupportNavigationPermissionsForTypes property to false.
This article demonstrates how to implement the first mode manually, and the method demonstrated in this article is useful if the version of XAF used by the project does not already implement navigation permissions.
Note: if you use the solution provided in this example and upgrade to version 16.2, this code may stop working properly. In this case, use the advice provided at the end of this article.
If your version of XAF is less than 16.2, and you need to grant permissions to a single navigation item (for example, DashboardView or a specific ListView model), extend the functionality of the security system using the solution described below. In this article, the HiddenNavigationItems attribute allows you to hide navigation items by their ID, which will be added to the role class.
The method of overriding the ShowNavigationItemController.SynchItemWithSecurity method shown in this article also applies to tasks that are not directly related to the security system, and you can hide or customize any navigation project in this way.
Implementation steps:
Implements a custom permission type, NavigationItemPermission, that can be used to check access to specific navigation items through its ID.
Implement a custom permission request-NavigationItemPermissionRequest-the request will be sent to check whether the current user has access to a navigation project.
Implement a custom permission request processor NavigationItemPermissionRequestProcessor, which determines whether the current user has permissions on the permission request received.
Use the HiddenNavigationItems property to implement a custom role. It is extended using the GetPermissions method to create an NavigationPermission instance based on the value of the HiddenNavigationItems property.
Specify a custom role in the RoleType property of the application designer security system.
Register the permission request handler in the application by handling the SecurityStrategy.CustomizeRequestProcessors event in the Program.cs and Global.asax.cs files.
Implement the descendant of ShowNavigationItemController-CustomShowNavigationItemController-and override its SynchItemWithSecurity method to disable navigation items prohibited by the CustomSecurityRole.HiddenNavigationItems property.
After performing these steps in the project, you will be able to assign roles with the HiddenNavigationItems attribute to the desired users to restrict their access to certain navigation items.
Note: this article is based on the PermissionPolicyRole and PermissionPolicyUser classes. These classes are used by the security system when you select the Allow/Deny permissions policy in the solution wizard. If your project was created with an earlier version of XAF (prior to 16.1) and uses the SecuritySystemRole and SecuritySystemUser classes, change the version number in the combo box below to see examples of these classes.
Upgrade instructions for v16.2:
After upgrading to this version, the code used in the older version of this sample may stop working. To resolve this problem, copy the relevant code from the new version of the example, or modify the CustomShowNavigationItemController class by adding the following methods:
C#
Protected override bool SyncItemsWithRequestSecurity (DevExpress.ExpressApp.Actions.ChoiceActionItemCollection items) {base.SyncItemsWithSecurity (items); return true;}
Visual Basic
Protected Overrides Function SyncItemsWithRequestSecurity (ByVal items As DevExpress.ExpressApp.Actions.ChoiceActionItemCollection) As Boolean MyBase.SyncItemsWithSecurity (items) Return True End Function above is how to hide navigation items according to the current user in the DevExpress shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.