Permissions can be associated to a GAM User through Roles or can be added to the user directly. The permissions added directly to the user have precedence over the others. See Permission Access Type for details.
In this paper you will see how to add (and delete) a Permission given to a User using the GAM API.
GAMUser.AddPermission(in:GAMPermission, out:GAMError Collection) : Boolean
In this example, add to the user the permission named "webpanel1_execute" with Permission Access Type = Allow.
The Permission to be added to the user needs to exist in any of the Applications. First, you need to define a GAMApplicationPermission type variable in order to get the GUID of the Permission.
Afterwards, define a GAMPermission type variable using the GUID obtained and the ApplicationId of the GAM Application.
The AddPermission Method of GAMUser receives the GAMPermission object and returns a collection of GAMError, as shown in the following code:
//&PermissionGUID is GAMGUID Data Type.
//&GAMPermission is GAMPermission Type.
&GAMPermission.GUID = &PermissionGUID
&GAMPermission.ApplicationId = &ApplicationId
&GAMPermission.Type = GAMPermissionAccessType.Allow
//&User is GAMUser Type.
&IsOK = &User.AddPermission(&GAMPermission, &Errors)
Given the GAMUser object you can remove a permission by executing the DeletePermissionById GAMUser Method.
You need to have the GUID of the Permission (as explained in the example above), and a collection of GAMError will be returned.
GAMUser.DeletePermissionById(in:GAMKeyNumLong, in:GAMGUID, out:GAMError Collection) : Boolean
//&user is GAMUser Type.
&IsOK = &user.DeletePermissionById(&ApplicationId,&PermissionGUID,&errors)
msg("Permiso borrado con éxito")
- There are other methods, like UpdatePermission and DeletePermission of GAMUser Object, with similar purposes.
- The way to know the list of permissions added directly to the user is by executing the GetPermissions method of GAM User object. See Get GAM User Permissions for more information on this topic.
Update GAM Application Permissions
Update GAM Role Permissions