I've made a couple of CGI apps with Delphi these past weeks and I recently
discovered a problem with the BDE:
I use IIS 2.0 (part of NT4) as a test web server, and it runs under an
account with guest priviligies. Everything works ok, but if I'm at the
console and I'm running e.g. BDECFG32, then the CGI apps are prevented
from using the BDE (IDAPI32.DLL)!
If I configure a directory to be accssible by only a couple of users, then
I will get the same problem. IIS will ask the browser for a user name and
password, and if one user has a different access level than say a guest user,
then the guest user will be denied access to IDAPI32.DLL.
The user at the console will see this error dialog:
"dbcgitest.exe - DLL Initialization Failed
Initialization of the dynamic link library
d:\prog\Borland\common files\bde\idapi32.dll failed.
The process is terminating abnormally."
When "OK" is pressed, the following appears in the web browser:
"Exception EDatabaseError in module dbcgitest.exe at 00030D56.
An error occurred while attempting to initialize the Borland Database Engine
(error $2108)."
To verify this for yourselves, all you need is NT4 Server with IIS running.
I've got the same results both at home (default setup) and at work.
Put the following program in your \inetpub\scripts directory and invoke
it from your browser as http://localhost/scripts/dbcgitest.exe. It will
normally work, but if you are logged in as say, administrator, and are using
another IDAPI32 app, like BDECFG32.EXE, it will fail.
--cut (dbCGITest.dpr)--
program dbCGITest;
{$APPTYPE CONSOLE}
uses windows, dbtables, db;
var i : integer;
begin
WriteLn('Content-type: text/html');
WriteLn;
with ttable.create(nil) do
try
DatabaseName := 'DBDEMOS';
TableName := 'Customer.db';
Open;
writeln('<table border>');
while not eof do
begin
write('<tr>');
for i := 0 to fieldcount - 1 do
Write('<td>', fields[i].AsString);
next;
end;
writeln('</table>');
finally
free;
end;
end.
--cut--
Workarounds (both non-options for me):
- grant IIS administrator access. Will pretty much make IIS unusable if you
wish to limit access to certain dirs
- limit usage of other BDE apps on the web server. Remotely make
modifications to idapi.cfg if necessary and generally only run db CGI
apps from the same user account.
FYI: Error $2108 translates to (from BDE.INT):
ERRCAT_SYSTEM = $2100
ERRCODE_CANTFINDIDAPI = 8; { Cannot locate IDAPIxx.DLL }
BTW: I tried copying the BDE files to the scripts directory, which resulted
in two-three message boxes being dumped in my face. It looked like it first
tried the idapi32.dll in the current directory, then went for the one in the
BDE directory, complaining as it tried to load each of them. :-)
Any takers?
--
=\ homepage @ http://www.qsd.no/staff/rune
*=- R.Moberg, CD-Player Pro info @ http://home.sn.no/home/mobergru/
=/ my own webserver @ http://pumba.qsd.no