expressappframework-devexpress-dot-persistent-dot-baseimpl-dot-permissionpolicy-dot-permissionpolicyuser.md
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
[Association]
public XPCollection<PermissionPolicyRole> Roles { get; }
<Association>
Public ReadOnly Property Roles As XPCollection(Of PermissionPolicyRole)
| Type | Description |
|---|---|
| XPCollection<PermissionPolicyRole> |
An XPCollection<PermissionPolicyRole> collection which is the list of roles associated with the current user.
|
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.
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
if (user != null) {
foreach (ExtendedSecurityRole role in user.Roles) {
if (role.CanExport) {
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
If user IsNot Nothing Then
For Each role As ExtendedSecurityRole In user.Roles
If role.CanExport Then
See Also