skip to main content
DataDirect Connect Drivers : Microsoft SQL Server Driver : Reauthentication
  
Reauthentication
The SQL Server driver supports reauthentication for Microsoft SQL Server 2005 and higher. The user performing the switch must have been granted the database permission IMPERSONATE.
See Using Reauthentication for an introduction to reauthentication. Refer to "Connection Pool Manager" in the DataDirect Connect Series for JDBC Reference for information about using reauthentication with the DataDirect Connection Pool Manager.
Note: Before performing reauthentication, applications must ensure that any statements or result sets created as one user are closed before switching the connection to another user.
Your application can use the setCurrentUser() method in the ExtConnection interface located in the com.ddtek.jdbc.extensions package to switch a user on a connection. The setCurrentUser() method accepts driver-specific reauthentication options. The reauthentication options supported for the SQL Server driver are:
*CURRENT_DATABASE specifies the name of the current database. The value must be a valid Microsoft SQL Server database name.
If the setCurrentUser() method is called and this option is specified as an empty string or is not specified, only the user is switched; the database is not switched.
*REVERT_USER determines whether the driver reverts the current user to the initial user before setting the user to a new user for connections that have already reauthenticated.
If set to true and the setCurrentUser() method is called, the driver reverts the current user to the initial user before setting the connection to the new user. For example, consider a connection that was initially created by User A and was later switched to User B. Before the connection could be further switched to User C, the driver reverts the connection back to User A and then sets it to User C.
If set to false and the setCurrentUser() method is called, the driver does not revert the current user to the initial user before performing the switch. For example, if the connection was initially created by User A, switched to User B, and then switched to User C, the driver does not revert the user to User A before switching to User C.
Refer to "JDBC Extensions" in the DataDirect Connect Series for JDBC Reference for more information about the setCurrentUser() method.