2
votes

I am trying to open a connection to DB2 in console application. It works fine. when I use the same code in a service, hosted in IIS it throws an error for DB2. Following is the error details. Am I missing some permissions in IIS ?

dll :IBM.data.DB2.dll

Code :

DB2Connection db2Connection = new DB2Connection(connectionString);
DB2Command cmdSelectUsrNameAndPassword = new DB2Command(querySelectUsernameAndPassword, db2Connection);
cmdSelectUsrNameAndPassword.Connection.Open();

Throws :

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 9.7.3

If I try a DSN with ODBC in console it works, but same throws another error in IIS.

OdbcConnection DbConnection = new OdbcConnection(DSNName);
DbConnection.Open();

Throws :

ASP.NET V4.0 does not have the authority to perform the requested command or operation.

5
guess it has something to do with App pool identity. I set the app pool identity as "Network service" and gave full permission to "Network Service" on "IBM.Data.DB.dll" in C:\Program Files\IBM\SQLLIB\BIN\netf20_32\ Worked neat.Shetty

5 Answers

3
votes

guess it has something to do with App pool identity. I set the app pool identity as "Network service" and gave full permission to "Network Service" on "IBM.Data.DB.dll" in C:\Program Files\IBM\SQLLIB\BIN\netf20_32\ Worked neat.

1
votes

Have a look at IBM support doc below which outlines why it happens and what the message means http://www-01.ibm.com/support/docview.wss?uid=swg21413731. It helped me, adding to the DB2USERS group allowed our app to work and is probably better than running as Network Service.

1
votes

While installing IBM data server client you did not uncheck the option to enable operating system security.

So you have to add the user(s), that need to use DB2 client dll, to DB2USERS group as it states in the final step of installation.

If you want IIS application pool identity use: "IIS AppPool\DefaultAppPool". Add that user to DB2USERS group. DefaultAppPool-> your application pool identity name

0
votes

I encountered a very similar error message on one of my projects:

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 10.1.5

Having tried all of the solutions listed above and on the IBM documentation site, it ultimately ended up just being the case that the DB2 Connect installer needed to be run as administrator, rather than as a user account. Uninstalling it and reinstalling it as administrator resolved the problem.

Running the installer as administrator also unlocked options such as the ability to turn off extended security which had previously not been presented.

0
votes

I had the same problem with an application running on IIS Express. Tried running Visual Studio as administrator and the problem is solved. Versions: DB2 Client Version 10.5, Visual Studio 2015.