The SQLSetConnectAttr() function with authentication

Use the SQLSetConnectAttr() function to specify the callback function used by the server.

SQLSetConnectAttr() is also used to specify what parameters are used by the callback function. Parameter attributes are passed back to the callback function exactly as they are specified to the driver.

The following attributes are HCL OneDB™-specific extensions to the ODBC standard:
Parameter Type Description
SQL_INFX_ATTR_PAM_FUNCTION void * A pointer to the callback function.
SQL_INFX_ATTR_PAM_RESPONSE_BUF void * A generic pointer to a buffer containing the response to an authentication challenge.
SQL_INFX_ATTR_PAM_RESPONSE_LEN int The length of the response buffer in bytes.
SQL_INFX_ATTR_PAM_RESPONSE_LEN_PTR int * The address which stores the number of bytes in the response.
SQL_INFX_ATTR_PAM_CHALLENGE_BUF void * A generic pointer to a buffer containing the authentication challenge. The driver stores any challenge received from the server into this buffer. If the buffer is not large enough to contain the challenge, the challenge is truncated. The callback function can detect this challenge by comparing the buffer length with the number of bytes in the challenge. It is up to the application developer to detect this situation and handle it correctly.
SQL_INFX_ATTR_PAM_CHALLENGE_BUF_LEN int The length of the challenge buffer in bytes.
SQL_INFX_ATTR_PAM_CHALLENGE_LEN_PTR int * The address that stores the number of bytes in the challenge.

The challenge and response buffer pointers can be null. If the authentication server requires the information that would be stored in these buffers, a connection failure results due to an authentication failure. The challenge length information is returned whether the connection is successful or not. If the message type does not require a response, the response buffer might be null (default) or it might contain an empty string.

The attributes in the previous table can be set at any time and in any order. However, they are only valid for connections established with subsequent calls to one of the driver's connect functions.

You can set the isolation level with the SQLSetConnectAttr() API by using one of the following connection attributes:
  • SQL_TXN_READ_UNCOMMITTED = Read Uncommitted
  • SQL_TXN_READ_COMMITTED = Read Committed
  • SQL_TXN_SERIALIZABLE = Serializable
  • SQL_TXN_REPEATABLE_READ = Repeatable Read
  • SQL_TXN_LAST_COMMITTED = Last Committed
  • SQL_TXN_TRANSACTION = Transaction

If you use the SQL_TXN_LAST_COMMITTED or SQL_TXN_TRANSACTION attributes with the SQLSetConnectAttr() API, then your applications must link directly to the HCL OneDB ODBC Driver instead of to the ODBC Driver Manager. However, if the attribute is specified in the odbc.ini file or the Data Source Administrator, the application can be linked with ODBC Driver Manager.

If you use the SQL_TXN_TRANSACTION attribute, then the isolation level set in the DTC application is propagated to the server. This option should be used only in Windows™ DTC applications.

The default behavior of the ODBC driver is to trim blank characters from the end of VARCHAR column results. To preserve trailing spaces, set the SQL_INFX_ATTR_LEAVE_TRAILING_SPACES attribute:
SQLSetConnectAttr( hdbc, SQL_INFX_ATTR_LEAVE_TRAILING_SPACES, 
(SQLPOINTER)SQL_TRUE, SQL_IS_INTEGER );
To trim trailing spaces, change SQL_TRUE to SQL_FALSE.

The behavior is limited to the connection.