Page 1 of 1

unable to create db using php

Posted: Wed Apr 09, 2003 4:24 am
by vram
Hi all
Anybody pls help me how to rectify the error in the below code.I created a webpage thru which i allow users to learn SQL thru DB2 UDB.Initially I created an instance which i set to environment variable. Then i attached the instance to the Win NT user name and password.My prj needs the db2 commands to be executed from a webpage.Actually i am able to execute all those db2 commands which needs no authorization.But when i tried to create sample db which has sysadm authority thru php,I enocounter this error "SQL1092N "SYSTEM" does not have the authority to perform the requested command".How to overcome this problem.I cannot change the design part now as time is too short.I need to create everything thru a webpage.So anybody who knows pls reply.I use Apache server.

Thanks in adv.Bye.
Thanks and regards
Vram


<?php //Start of PHP
session_start(); //Staring a SESSION
$_SESSION['instance']=$_POST[instance];
$_SESSION['Login']=$_POST[Login];
$_SESSION['pwd']=$_POST[pwd];
$instance=$_SESSION['instance'];
$Login=$_SESSION['Login'];
$pwd=$_SESSION['pwd'];


system('db2admin stop');
echo "<br>";

$dbad="db2admin setid ".$Login." ".$pwd;
system($dbad);
echo "<br>";


system('db2admin start');
echo "<br>";


$instance contains the instance name obtained from the previous page in a form
//ly $login and $pwd contains the domain username and password

system('db2stop'); //Stopping the current instance

$ins="db2icrt ".$instance." -s ee -p D:\ -u ".$Login.",".$pwd;
system($ins); //Executing $ins


echo "<BR>Instance ($instance) created succseefully";
prints::Instance (newinst) created succseefully

putenv("db2instance=$instance"); Setting the current instance to env variable


echo "<BR>";
system('db2cmd /c /w /i db2 get instance');

Prints ::The current database manager instance is: NEWINST

echo "<BR>";


system('db2start');
Prints::
SQL5043N Support for one or more communications protocols failed to start successfully. However, core database manager functionality started successfully.


system('db2sampl');
Prints::
SQL1092N "SYSTEM" does not have the authority to perform the requested command

session_write_close();


?> //End of PHP

Posted: Wed Apr 09, 2003 8:32 am
by volka
can you explain the usage of db2admin, db2cmd, ... ?
Maybe it helps you to know, that system() is (more or less) like opening a dos-box, executing the command and closing the box for each call of system(). Would that work if you did that manually?

Posted: Wed Apr 09, 2003 11:12 am
by Bitmaster
You said something about Win NT, so I assume your web server runs as an NT service. By default, NT services run in the context of the "SYSTEM" user account, but that can be changed in the Control Panel / Services applet. Probably the user account under wich your database server and Web server run (for Microsoft IIS, user name is IUSR_ComputerName, not SYSTEM) does not have enough access rights to create the physical file that will contain the db. Check your access permissions.