none
Cannot connect to SQL Server using Window Authentication

    Question

  • 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 (9.0.4.35)
    SQL Server Driver for PHP (Version 1.0)
    PHP 5.2.9-2
    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:
    http://blogs.msdn.com/lcris/archive/2008/02/21/sql-server-2005-how-to-debug-login-failures-18456-anyone.aspx
    http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx

    Following is the code I have been trying to connect with:
    <?php
    /* 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 ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [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$'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [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$'. ) )

    Wednesday, May 27, 2009 9:45 PM

Answers