Set session variables via logon script

As part of a GAPTEQ application, a logon script that can execute SQL statements and database procedures is processed each time a user logs in.

In this article you will read the following content:

Available system parameters for SQL statement

Generate SQL statement

Note! The GAPTEQ server provides session variables that are used in the SQL statements to, for example:

  • create a mapping between GAPTEQ users and information from the database (e.g. employees),
  • set user group membership based on database queries (custom role groups)
  • execute service scripts/statements

1. Available system parameters for SQL statement


The following system parameters can be used in the SQL statements: 


@login (login string of the logged-in user)
@user_id (ID of the logged-in user)
@user_guid (GUID of the logged-in user)
@fullname (name of the user)
@email (e-mail of the user)
@group_names (comma-separated string with the user groups of the logged-in user)


Note! The usable/provided system parameters are listed in the Database Connections and “Parameters”.

TD_FT_LogonScript

2. Generate SQL statement

Tip! Clicking on “Skeleton” in the menu inserts a script skeleton into the editor, which shows the necessary syntax for the respective use case.

  • In the “Statement” tab, you can describe session variables with values from database queries. A session variable must be created in advance in order to be able to describe it here (see Setting session variables).
  • Variables that have already been defined can be selected in the “Output Parameters” menu.

TD_FT_SessionVariablen_Screenshot_4

Note! Your custom role groups are displayed under “Output parameters” if you have created them in the repository configurations. The group membership is finally defined here. The value “true” or “false” is expected.

TD_FT_DatabaseConnectionLogon_Screenshot_2-png

  • User / Group / User/Group mapping

TD_FT_DatabaseConnectionLogon_Screenshot_3-png

TD_FT_DatabaseConnectionLogon_Screenshot_4-png

TD_FT_DatabaseConnectionLogon_Screenshot_5-png