php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #57256 Can't get ibm_db2 to work with IIS
Submitted: 2006-09-22 20:18 UTC Modified: 2007-03-22 13:42 UTC
From: larry dot menard at rogers dot com Assigned: tessus (profile)
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.2.0 RC6 OS: Windows XP, SP2
Private report: No CVE-ID: None
 [2006-09-22 20:18 UTC] larry dot menard at rogers dot com
Description:
------------
(I'm actually using PHP 5.2.0RC5-dev, but it is not listed in the selection box.)

First I had problems getting the ibm_db2 extension to load at all.  I had to grant Read and Execute permission to the "IUSR_CS288290-A" account (my host name is CS288290-A) on both the "sqllib\bin" and "sqllib\lib" directories.  This should be documented somewhere.

After that I found that even a simple test script does not work when run against an IIS server.

I know that the db2_connect() is truly not successful because a db2trc shows no DB2 server activity at all.

And as you can see, the db2_conn_error() does not seem to pick up the fact that the db2_connect() failed.

It works fine against an Apache server and when run via the command prompt.

I really would like to get ibm_db2 to work with IIS, but there's no documentation anywhere regarding this.

Please advise.

Thanks.

Reproduce code:
---------------
<?php
if (key_exists('SERVER_SOFTWARE', $_SERVER)) $br = "<br>";
else $br = "\n";

$dbname = "mydbname";
$userid = "myuserid";
$password = "mypasswd";

printf("Calling db2_connect()...${br}");
$dbconn = db2_connect($dbname, $username, $password);
printf("Returned from db2_connect().${br}");
 
printf("\$dbconn = ");
var_dump($dbconn);
printf("${br}");
 
printf("db2_conn_error() returns: ");
var_dump(db2_conn_error());
printf("${br}");

if (db2_conn_error()) // db2_connect() is apparently failing but this doesn't seem to be returning true
{
  printf("Connect failed.${br}");
  printf("%s.${br}", db2_conn_errormsg ());
}
else
{
  printf("Connect successful.${br}");
  db2_close($dbconn);
}
 
exit;
?>

Expected result:
----------------
Calling db2_connect()...
Returned from db2_connect().
db2_conn_error() returns: string(0) ""

$dbconn = resource(4) of type (DB2 Connection)
 
Connect successful.

Actual result:
--------------
Calling db2_connect()...
Returned from db2_connect().
$dbconn = bool(false) 
db2_conn_error() returns: string(0) ""
Connect successful.

Warning: db2_close() expects parameter 1 to be resource, boolean given in C:\MyServer\testIISDB2.php on line 52
PHP Warning: db2_close() expects parameter 1 to be resource, boolean given in C:\MyServer\testIISDB2.php on line 52 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-22 20:20 UTC] larry dot menard at rogers dot com
Typo in the repro code... "$userid" should be "$username".  Sorry.  :-)
 [2006-09-22 20:24 UTC] pierre dot php at gmail dot com
Not a "Bug System" bug > ibm_db2
 [2006-09-22 23:10 UTC] helmut_tessarek at evermeet dot cx
We know about that problem and are working on it. This really seems to be an IIS related problem, because the same module works with Apache as it should.
 [2006-09-23 05:27 UTC] larry dot menard at rogers dot com
Thanks, Helmut.  I'm rather desperate to get off of Apache, so if there's anything I can do to expedite a solution, please let me know.  :-)
 [2006-09-23 07:41 UTC] helmut_tessarek at evermeet dot cx
Hi Larry,

Which version of IIS is affected? I've seen this problem on IIS 5.1, but unfortunately I was not able to get an IIS 6 to test it on. I'm just curious, if it would work on IIS 6.
 [2006-09-23 14:57 UTC] larry dot menard at rogers dot com
Hi Helmut.

My IIS is 5.1 as well.  It looks like IIS 6.0 only runs on Server versions of Windows.
 [2006-09-25 10:38 UTC] larry dot menard at rogers dot com
If it would help, I'd be willing to try to do some debugging of this myself, but I'm not familiar with PECL/PEAR build environments.

I found file "C:\Program Files\PHP\PEAR\go-pear.phar", but when I run it I get numerous errors, including a lot of the following 2 errors:

PHP Warning:  Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Command.php on line 268

Could not get contents of package "". Invalid tgz file.
Cannot initialize 'phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.1.tar', invalid or missing package file

If you can help get me started I'll try to do some debugging of the driver myself.
 [2006-10-23 14:34 UTC] kfbombar at us dot ibm dot com
Hi Larry,

I have been trying to resolve this issue for sometime now and I have gotten my IIS setup working now on Win XP/DB2 Express C V9/ibm_db2 1.5.1.  The main issue was permission problems with the IIS users created to connect to DB2.  It was a matter of adding the IUSER_COMPNAME to the respective database on the DB2 Control Center.  Also ensuring that the group they belong to had the connect permissions in the DB2 Control Center.  Another important part was ensuring that your connection string had the correct hostname (not localhost but the name of the computer in the DB2 Control Center).  Here is my script that I tested with:

<?php
if (key_exists('SERVER_SOFTWARE', $_SERVER)) $br = "<br>";
else $br = "\n";

printf("Calling db2_connect()...${br}");
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TESTDB;HOSTNAME=MYHOSTNAME;PORT=50000;PROTOCOL=tcpip;UID=myuser;PWD=******;";
$dbconn = db2_connect($conn_string, '', '');
printf("Returned from db2_connect().${br}");
 
printf("\$dbconn = ");
var_dump($dbconn);
printf("${br}");
 
printf("db2_conn_error() returns: ");
var_dump(db2_conn_error());
printf("${br}");

if (db2_conn_error()) // db2_connect() is apparently failing but this
{
  printf("Connect failed.${br}");
  printf("%s.${br}", db2_conn_errormsg ());
}
else
{
  printf("Connect successful.${br}");
  db2_close($dbconn);
}
 
exit;
?>

The results from this script now show:

Calling db2_connect()...
Returned from db2_connect().
$dbconn = resource(1) of type (DB2 Connection)
db2_conn_error() returns: string(0) ""
Connect successful.



If you do not understand what is needed to get this working or anything else, please feel free to contact me.

--Kellen (kfbombar)
 [2006-11-18 17:00 UTC] larry dot menard at rogers dot com
After *much* screwing around, this is what I found:

- Granting IUSR_CS288290-A full permissions via Control Center did not help. 

- The connection string syntax didn't matter. 

- Adding IUSR_<computername> to the "Administrators" Group (and rebooting) works.  This seems to be the only change necessary... no other Group assignments or database authorities required.

However, I have concerns about this solution.  Isn't it a security exposure?  Can this account be hijacked or used maliciously?
 [2006-11-18 22:34 UTC] larry dot menard at rogers dot com
On the advice of another Gallery developer, I gabbed a copy of filemon from sysinternals, and found two file "Access Denied" errors.  I resolved tham by granting IUSR_<computername> read access to "sqllib\cli.ini" and "sqllib\DB2\db2systm".

The script still doesn't work, but the symptom has changed somewhat.  Now it is at least correctly detecting the connect failure:

db2_conn_error() returns: string(5) "08003" 
[IBM][CLI Driver] CLI0106E Connection is closed. SQLSTATE=08003 SQLCODE=-99999.

The filemon trace is at http://cpe0013102da23b-cm0f0079804905.cpe.net.cable.rogers.com/misc/Gallery2/DB2_IIS/Filemon.zip
 [2007-01-12 10:25 UTC] helmut_tessarek at evermeet dot cx
Hi Larry,

I was able to setup a machine with WinXP SP2, IIS 5.1, PHP 5.2.0 and DB2 9.
I have installed DB2 with extended operating system security.
I have added the PHP binary path (c:\php\) to the PATH and set another system environment variable:
PHPRC = c:\php\
Then I have added the IUSR_COMPUTERNAME to the DB2USERS group.
Now everything works as it should.

Please tell me your feedback asap. I will leave the bug open until your answer.

Regards,
   Helmut
 [2007-01-12 12:02 UTC] helmut_tessarek at evermeet dot cx
changed bug type, since it is not a bug
 [2007-02-02 08:27 UTC] helmut_tessarek at evermeet dot cx
Hi Larry,

I will leave this bug open until the end of next week.
Since I haven't received any feedback yet, I guess everything works as it should.

So long,
  Helmut
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 15:01:30 2019 UTC