Search code examples
rdb2ibm-midrangerodbcdb2-400

Trusted connection RODBC to db2 - syntax


I would like to use trusted connection when connecting to our DB2 database. As far as we know it should be possible... But I have a hard time finding info on how to do it.

The code below works when I supply my pwd and uid but not trusted connection.

My question is are we wrong when thinking we can use trusted connection and that's why it fails or is the syntax wrong and it "might" succed with correct syntax?

I got tons of results when looking for SQL-Server but DB2 is more of a black box...

Code:

library(RODBC)

kSysName <- "MySys"
kDbName <- "MyDB"

contst <- odbcDriverConnect("Driver=iSeries Access ODBC Driver;
                            System = kSysName; Database=kDbName; 
                            Trusted_Connection = Yes")

Error code:

ERROR: state 28000, code 8015

This works:

uid <- "MyUserName"
pwd <- "MyPwd"
contst <- odbcDriverConnect("Driver=iSeries Access ODBC Driver;
                             System = kSysName; Database=kDbName; 
                             uid = uid; pwd = pwd")

Edit: We're on a iSeries/IBM for this application, other stuff uses SQL-Server


Solution

  • The term IBM uses for trusted connection is single sign-on. Once you have single sign-on set up with IBM i, you will be able to use your windows login across ODBC to access DB2. That is what is happening with Windows and Active Directory. Until you do that, IBM i has nothing to trust. Here is a manual that explains it in more detail:

    https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzamz/rzamzpdf.pdf