Get GAM User Permissions

Official Content
This documentation is valid for:

There exist three methods in order to get the GAM Permissions of a given user, which we detail below.

GetPermissions Method

It returns a collection of GAMPermission Object of the GeneXus Access Manager Library, which corresponds to all the permissions which have been granted to the user directly (not through roles). See Update GAM User Permissions for more information about adding permissions to a user.

Syntax

&GAMUser.GetPermissions(in:GAMPermissionFilter,out:GAMError Collection):  GAMPermission Collection

Example

//Set the Filters for the GetPermissions method
&GAMPermissionFilter.ApplicationId = &ApplicationId
&GAMPermissionFilter.AccessType = GAMPermissionAccessType.Convert(&GAMPermissionAccessType) //&GAMPermissionAccessType is character(1). Valid values are: A (Allow),D (Deny), R (Restricted)
&GAMPermissions = &User.GetPermissions(&GAMPermissionFilter,&errors) //&GAMPermissions is GAMPermission Collection, &User is GAMUser 

for &GAMPermission in &GAMPermissions

    &GAMPermissionGUID = &GAMPermission.GUID
    &GAMPermissionName = &GAMPermission.Name
 
endfor
do 'display errors'

sub 'display errors'
for &error in &errors
  msg(&error.Code.ToString() + ' ' + &error.Message)
endfor
endsub

Note

The valid values for &GAMPermissionFilter.AccessType given to GetPermissions method are: A (Allow),D (Deny), R (Restricted).

GetAllPermissions Method

It returns a collection of GAMPermission Object, which corresponds to all the permissions associated to the user (through roles or directly to the User), which fulfill the GAMPermissionFilter conditions.

Syntax

&GAMUser.GetAllPermissions(in:GAMPermissionFilter,out:GAMError Collection):  GAMPermission Collection

Example

Similar to the previous example, in this case the only valid values for the GAMPermissionFilter.AccessType are Allow and Deny.

//Set the Filters for the GetAllPermissions method
&GAMPermissionFilter.ApplicationId = &ApplicationId
&GAMPermissionFilter.AccessType = GAMPermissionAccessType.Convert(&GAMPermissionAccessType) //Only A (Allow) or D (Deny)
&GAMPermissions = &User.GetAllPermissions(&GAMPermissionFilter,&errors)

for &GAMPermission in &GAMPermissions
   &GAMPermissionGUID = &GAMPermission.GUID
   &GAMPermissionName = &GAMPermission.Name
endfor
do 'display errors'

Note

The valid values for &GAMPermissionFilter.AccessType given to GetAllPermissions method are: A (Allow),D (Deny)

GetUnassigned Permissions Method

It returns a collection of GAMPermission Object, which corresponds to all the permissions which the user has through the associaton to a role only.

Syntax

&GAMUser.GetUnAssignedPermissions(in:GAMPermissionFilter,out:GAMError Collection):  GAMPermission Collection

Example

//Set the Filters for the GetUnassignedPermissions method

&GAMPermissionFilter.ApplicationId = &ApplicationId
&GAMPermissionFilter.AccessType = GAMPermissionAccessType.Convert(&GAMPermissionAccessType) //Valid values are: A (Allow),D (Deny), R (Restricted)

&GAMPermissions = &User.GetUnassignedPermissions(&GAMPermissionFilter,&errors)

for &GAMPermission in &GAMPermissions
   &GAMPermissionGUID = &GAMPermission.GUID
   &GAMPermissionName = &GAMPermission.Name
endfor
do 'display errors'

Note

The valid values for &GAMPermissionFilter.AccessType given to GetUnassignedPermissions method are: A (Allow),D (Deny), R (Restricted).






Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.