Code
1 Owner = Session.GetObjectByKey<PermissionPolicyUser>(SecuritySystem.CurrentUserId);
User Properties
Functionality of the application may depend on the current user. Therefore, the need to obtain a user name, user ID or whole user objects. The following properties are disclosed SecuritySystem class.
- SecuritySystem.CurrentUserName - the current user name
- SecuritySystem.CurrentUserId - current user ID
- SecuritySystem.UserType - current user type
- SecuritySystem.CurrentUser - current user
SecuritySystem.CurrentUser属性
1 using DevExpress.ExpressApp; 2 using DevExpress.ExpressApp.Actions; 3 using DevExpress.Persistent.Base; 4 // ... 5 public class ShowCurrentUserController : WindowController { 6 public ShowCurrentUserController() { 7 PopupWindowShowAction showCurrentUserAction = new PopupWindowShowAction( 8 this, "ShowCurrentUser", PredefinedCategory.Edit); 9 showCurrentUserAction.CustomizePopupWindowParams += ShowCurrentUserAction_CustomizePopupWindowParams; 10 } 11 12 private void ShowCurrentUserAction_CustomizePopupWindowParams( 13 object sender, CustomizePopupWindowParamsEventArgs e) { 14 IObjectSpace newObjectSpace = Application.CreateObjectSpace(SecuritySystem.CurrentUser.GetType()); 15 object currentUser = newObjectSpace.GetObject(SecuritySystem.CurrentUser); 16 e.View = Application.CreateDetailView(newObjectSpace, currentUser); 17 } 18 }
The current standard user access
When a user needs to use the current filter condition, use the function CurrentUserId operator criteria.
Initialize the object owner
The current object reference assigned to the Owner object.
1 void IXafEntityObject.OnCreated() { 2 Owner = objectSpace.GetObjectByKey<PermissionPolicyUser>(SecuritySystem.CurrentUserId); 3 }
XPO objects
1 public override void AfterConstruction() { 2 base.AfterConstruction(); 3 if (SecuritySystem.CurrentUser != null) { 4 Owner = Session.GetObjectByKey<PermissionPolicyUser>(SecuritySystem.CurrentUserId); 5 } 6 }
According to the object owners configure permissions
Add the type of permissions you want to filter the type of object, and set its AllowRead property to false.
To add an object type permissions permissions to AllowRead property is set to true, the Criteria property to "Owner". Oid = CurrentUserId () ".
Reference Site
[1] https://documentation.devexpress.com/eXpressAppFramework/113152/Task-Based-Help/Security/How-to-Get-the-Current-User-in-Code