FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Calling stored procedure on remote SQL Server machine with PDO
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Calling stored procedure on remote SQL Server machine with PDO [message #175097 is a reply to message #175053] Sun, 14 August 2011 19:29 Go to previous message
Heiko Richler is currently offline  Heiko Richler
Messages: 2
Registered: January 2011
Karma:
Junior Member
Am 09.08.2011 01:12, schrieb Marchand:
> Both our Web server (Server A, running IIS 7.0) and the server running
> SQL Server (Server B) are Windows Server 2008 boxes, both in the same
> domain. I'm trying to find a way to have a PHP file on Server A
> execute a SQL stored procedure on Server B, and failing miserably. Any
> advice would be most welcome -- the code is below.

I can call Stored Procedures from PHP 5.3. Can you execute the SPs using
the same Login in SQL Server Management Studio?


dsn='sqlsrv:server=Sql;Database=Northwind;';
$db = new PDO($dsn, $user, $password);
$sql = 'Exec MySQL:PID, :LSTR, :PSTR';
$sth = $db->prepare($sql,
array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->bindValue(':PID', $PID, PDO::PARAM_INT);
$sth->bindValue(':LSTR', $values['LSTR'], PDO::PARAM_STR);
$sth->bindValue(':PSTR', $values['PSTR'], PDO::PARAM_STR);
$sth->execute();

> Some observations:
>> Setting the $uid and $pwd values to the "sa" parameters for the database don't work; nor does setting them to a domain account with appropriate rights within SQL Server. I generally get the idea that it's the service running PHP which actually executes the code, but since IIS is running under a local Server B account -- and that can't change for political reasons -- I'm looking for a way around that. It seems that the $uid/$pwd are effectively ignored when calling into a remote server (?!).

My IIS is runing a none AD-User, too. I am using a SQL-User on the
SQL-Server.

>
>> Since IIS is running under a local account, Server B can't "see" Server A so as to add users on that machine/domain into groups on Server B on either the Windows or the SQL Server level. (Or at least I can't find a way to do that).
>

Did you give Execute rights to that user on the Stored Procedures?
http://msdn.microsoft.com/en-us/library/ms345484.aspx

Heiko
[Message index]
 
Read Message
Read Message
Previous Topic: to fill a select with json javascript from arrays
Next Topic: PHP 4 vs 5 timings
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 22:28:36 GMT 2024

Total time taken to generate the page: 0.05231 seconds