Skip to main content
Version: 2022


When using connection pooling or IAM authentication, the IAM user ID cannot be retrieved on the RDBMS using database functions like user_name(), system_user or USER.

Because the user ID is often used in queries (e.g., to fill trace columns or filter data), the user interfaces and service tiers use platform specific methods to provide the username in the context of every database connection.

The tsf_user() function is provided to retrieve the correct username from SQL logic.


The tsf_user() does not return the correct user ID when called by Crystal Reports reports. You can provide the user ID to the report by using an input parameters. Make sure to always set the user ID in the default so that the value can not be tampered with when using Indicium.

SQL Server

For SQL Server database connections, the CONTEXT_INFO is set by the user interface or the Indicium application tier for the current session or batch using the following command:

declare @binvar varbinary(128);
set @binvar = cast(@username as varbinary(128));
set context_info @binvar;

To get the username in SQL, use the tsf_user() function:

select dbo.tsf_user();


For DB2 database connections, the client user ID is set in the connection string, using the ClientUserID parameter.

To get the username in SQL, use the following statement:

select tsf_user() from sysibm.sysdummy1;


For Oracle database connections, the ClientId property is set for the connection after the connection is opened.

To get the username in SQL, use the following statement:

select tsf_user() from dual;


For Azure, function tsf_user will return Azure users instead of system users.

In rare cases, it is desirable to deviate from the logged-in user and select a different user. For this, we recommended altering the CONTEXT_INFO as described here: SQL Server.

Was this page helpful?

Happy React is loading...