Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2803
| From | Heiko Richler <heiko-richler@nefkom.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Calling stored procedure on remote SQL Server machine with PDO |
| Date | 2011-08-14 21:29 +0200 |
| Organization | (posted via) M-net Telekommunikations GmbH |
| Message-ID | <4E48221B.3040404@nefkom.net> (permalink) |
| References | <f460b76a-b059-40f4-a50c-c2ee7c501ab3@v9g2000pri.googlegroups.com> |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
Calling stored procedure on remote SQL Server machine with PDO Marchand <mvanwaas@gmail.com> - 2011-08-08 16:12 -0700 Re: Calling stored procedure on remote SQL Server machine with PDO Heiko Richler <heiko-richler@nefkom.net> - 2011-08-14 21:29 +0200
csiph-web