Back to Devexpress

PermissionPolicyUser.Roles Property

expressappframework-devexpress-dot-persistent-dot-baseimpl-dot-permissionpolicy-dot-permissionpolicyuser.md

latest4.6 KB
Original Source

PermissionPolicyUser.Roles Property

A list of roles associated with the current user.

Namespace : DevExpress.Persistent.BaseImpl.PermissionPolicy

Assembly : DevExpress.Persistent.BaseImpl.Xpo.v25.2.dll

NuGet Package : DevExpress.Persistent.BaseImpl.Xpo

Declaration

csharp
[Association]
public XPCollection<PermissionPolicyRole> Roles { get; }
vb
<Association>
Public ReadOnly Property Roles As XPCollection(Of PermissionPolicyRole)

Property Value

TypeDescription
XPCollection<PermissionPolicyRole>

An XPCollection<PermissionPolicyRole> collection which is the list of roles associated with the current user.

|

Remarks

In XAF applications, permissions are not assigned to a user directly. Users have roles, which in turn are characterized by a permission set. So, each user has one or more roles that determine what actions can be performed.

An example of using this property is provided in the Client-Side Security (2-Tier Architecture) topic.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Roles property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

xaf-how-to-implement-a-custom-security-operation-that-can-be-permitted-at-the-type-level/CS/CustomSecurityOperation.Web/Global.asax.cs#L46

csharp
if (user != null) {
    foreach (PermissionPolicyRole role in user.Roles) {
        foreach (PermissionPolicyTypePermissionObject persistentPermission in role.TypePermissions) {

XAF-implement-custom-permission-role-and-user-objects/CS/SecuredExportExample.Win/Program.cs#L40

csharp
if (user != null) {
    foreach (ExtendedSecurityRole role in user.Roles) {
        if (role.CanExport) {

xaf-how-to-implement-a-custom-security-operation-that-can-be-permitted-at-the-type-level/VB/CustomSecurityOperation.Win/Program.vb#L46

vb
If user IsNot Nothing Then
    For Each role As PermissionPolicyRole In user.Roles
        For Each persistentPermission As PermissionPolicyTypePermissionObject In role.TypePermissions

XAF-implement-custom-permission-role-and-user-objects/VB/SecuredExportExample.Web/Global.asax.vb#L41

vb
If user IsNot Nothing Then
    For Each role As ExtendedSecurityRole In user.Roles
        If role.CanExport Then

See Also

PermissionPolicyUser Class

PermissionPolicyUser Members

DevExpress.Persistent.BaseImpl.PermissionPolicy Namespace