This document explains the best way to identify GAM Users. The User Identity can be obtained in different ways:
There are different ways to get the User GUID.
The following is a static method. The static methods refer to the currently logged in user:
&UserIdentification = GAMUser.GetId() //&UserIdentification is GAMGUID Data Type
Another way is to use the active session:
&GAMSession= GAMSession.Get(&GAMErrors) //&GAMErrors is Collection of GAMError Data Type
&User = &GAMSession.User //&User is GAMUser Data Type
&UserIdentification = &User.GetId() //&UserIdentification is GAMGUID Data Type
Very similar would be:
&UserIdentification = &GAMSession.User.GUID
Information of the user can be obtained from these variables.
There are other ways which can be used to get the User identity
As GAM supports many authentication types, the UserName is not a unique key in GAM Users table. If the application will support only one type of authentication, it can be used.
&UserNick = GAMUser.GetName() //&UserNick is GAMUserIdentification Data Type
UserLogin is a string which contains Namespace\AuthenticationType\UserName, for example: miapp\local\jhon.
UserLogin is a unique key in GAM Users table, because it identifies the user in each Authentication Type.
&User = &GAMSession.User
&Userlogin = &User.GetLogin() //&Userlogin is GAMUserLogin Data Type
GAM Users can be mapped to users in the application database, by the externalId attribute.
When a new user is created using GAM Web Backoffice, or the GAM API, you can specify the externalId of the GAM User, which maps to the User Identification in the Users table of the application Database.
&GAMUser.externalId = &UserIdentification
When you need to do the opposite operation, that means, get the user identification who is logged in, you first need to get the externalId of the user:
&UserIdentification = GAMUser.GetExternalId()
See HowTo: Mapping Application Users to GAM Users - Using ExternalID GAMUser property for an example of use of externalId GAM User attribute.