I am trying to connect over the network to an SQL Server database. There is no Instance Name associated with the database. Using SQL Server Authentication (with a different login from my network login) I was able to connect.
I am using:
SQL Server 2005 (220.127.116.11)
SQL Server Driver for PHP (Version 1.0)
Apache Web Server Version 2.2.11
Laptop: Dell Latitude D820 running Microsoft Windows XP Professional version 5.1.2600
Web sites that I have tried include:
MSDN SQL Server Developer Center Library.. many pages
Two forum posts that were of particular help for connecting using SQL Server Authentication
Googled error and read several blogs including:
Following is the code I have been trying to connect with:
/* Specify the server and connection string attributes. */
$serverName = "serverName";
$connectionInfo = array( "Database"=>"saws");
/* Connect using Windows Authentication. */
$conn = sqlsrv_connect($serverName, $connectionInfo);
if( $conn === false )
echo "Unable to connect.</br>";
die( print_r( sqlsrv_errors(), true));
The error I get:
Unable to connect.
Array (  => Array (  => 28000 [SQLSTATE] => 28000  => 18456 [code] => 18456  => [Microsoft][SQL Native Client][SQL Server]Login failed for user 'networkName\ComputerName$'. [message] => [Microsoft][SQL Native Client][SQL Server]Login failed for user '(networkName\ComputerName$'. )  => Array (  => 28000 [SQLSTATE] => 28000  => 18456 [code] => 18456  => [Microsoft][SQL Native Client][SQL Server]Login failed for user 'networkName\ComputerName$'. [message] => [Microsoft][SQL Native Client][SQL Server]Login failed for user 'networkName\ComputerName$'. ) )
This is from How to: Connect Using Windows Authentication:
By default, the SQL Server Driver for PHP uses Windows Authentication to connect to SQL Server. It is important to notice that in most scenarios, this means that the Web server's process identity or thread identity (if the Web server is using impersonation) is used to connect to the server, not an end-user's identity.
It sounds like this might be the problem: There isn't a login on the server for the identity being used to establish the connection. I'm not sure how to change Apache's process identity, but I'd start investigating there. Or, you could try SQL Server Authentication: How to: Connect Using SQL Server Authentication.
Hope that helps.
This posting is provided "AS IS" with no warranties, and confers no rights.