Get GAM User Roles

Official Content
This documentation is valid for:

The GAMUser object of the GeneXus Access Manager Library provides methods to obtain the user's GAM Roles.

They are as follows:

  • (Boolean) GAMUser.CheckRole(String: RoleName) 
  • (Boolean) GAMUser.CheckRoleById(Numeric: RoleId) 
  • (Boolean) GAMUser.CheckRoleByGUID(GUID: RoleGUID) 
  • (Boolean) GAMUser.CheckRoleByExternalId(String: RoleExternalId) 

The following methods of the GAMRepository object are the same as the previous ones:

  • (Boolean) GAMRepository.CheckRole(String: RoleName) 
  • (Boolean) GAMRepository.CheckRoleById(Numeric: RoleId) 
  • (Boolean) GAMRepository.CheckRoleByGUID(GUID: RoleGUID) 
  • (Boolean) GAMRepository.CheckRoleByExternalId(String: RoleExternalId) 

These methods return true when the role is associated with the user or when the role is a descendant of a role associated with the user.

Example

The following code is present in the Start Event of the GAMMasterpage object:

If GAMUser.CheckRoleByExternalId(!"is_gam_administrator")
        Header1.Object= GAMHeader.Create(ContHolder1.Pgmname)
        //OK
    Else
        GAMExampleNotAuthorized.Link()
    Endif    

Other methods available:

  • GetRoles Method

Returns a collection of Roles which have been associated with the User.

Syntax:

GAMUser.GetRoles(out:GAMError Collection): GAMRole Collection

  • GetAllRoles Method

Returns a collection of Roles which have been associated with the User and their descendants.

Syntax:

GAMUser.GetRoles(out:GAMError Collection): GAMRole Collection

Note

These methods do not consider the Require Access Permissions Application Property. That is, you can manage roles in your application but not permissions because they are independent of each other.

See Also

HowTo: Get all users which have a given set of roles