Send feedback on this topic.
Teradata.Client.Provider
Trusted Session
.NET Data Provider for Teradata > Developer's Guide > Working with the Teradata Database Features > Working with Query Bands > Trusted Session

A Trusted Session is defined using Query Banding. To setup a Trusted Session, the keys ProxyUser and ProxyRole are used. The values used to define the ProxyUser and ProxyRole have corresponding access rights in the Advanced SQL Engine. The ProxyUser is associated with a user of an application. This user does not need an account in the Advanced SQL Engine. The ProxyRole identifies the role that a given proxy user is operating within. The role is granted privileges to perform specific actions within the database. Refer to the SQL Engine Manuals for more information.

Trusted Sessions are supported in Teradata Database version 13.0 or greater. If the provider is connected to a 12.0 version of a Teradata Database and the ProxyUser and ProxyRole have been defined in a TdQueryBand instance, a TdException will be thrown indicating that the SQL Engine does not support Trusted Session.

An example of a key=value pair using ProxyUser and ProxyRole is as follows:

   ProxyUser=user1;ProxyRole=role1;

The Teradata provider supports Trusted Session and Query Banding at both the connection and transaction level. If the ProxyUser and/or ProxyRole is specified at both the connection and transaction levels, the Query Band at the transaction level overrides the one at the connection level.

For more information on Query Banding refer to the Teradata Manual, SQL Data Definition Language Detailed Topics.

The following demonstrates how to set up a trusted session:

C#
Copy Code
Public void TrustedSessionDemo()
{
   TdConnectionStringBuilder sb = new TdConnectionStringBuilder();

   // Setting the connection string using the connection string builder.
   sb.DataSource = "teradata1";
   sb.UserId = "user1";
   sb.Password = "pass1";

   // The ProxyUser is used to assert the identity of the application user.
   sb.QueryBand = "ProxyUser = appuser1;ApplicationName = App1;"

   TdConnection tc = new TdConnection(sb.ToString());

   tc.Open();

   // Retrieving the Connection level Query Bands.
   TdQueryBand cqb = tc.QueryBand;

   // Any Query Band can be modified after connecting to Teradata.
   cqb["ProxyUser"] = "user2";
   // Removing the custom Query Band. The Remove method could also be called.
   cbq["ApplicationName"] = null;
   // After all the specified Query Bands have been modified, they need to be applied
   tc.ChangeQueryBand( cqb);

   //
   // Application performs it required tasks
   //

   tc.Close();

}