SQL Server 2008 PHP 5.5.7 Connection Windows Authentication Error

I am trying to establish a connection to SQL Server 2008 using the code shown below.  I'm also showing below the error message returned.  It seems that windows authentication is not quite working properly as it is passing my PC name rather than my windows logon and password.  Obviously SQL Server will refuse this connection since there is no user like my PC Name.  My question is how do I make Windows Authentication work properly?  
--scroll down to see the other two scripts I've tried:
<?php
$serverName = "serverName, 1433"; 

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"dbName");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Open in new window


Here is the error message I receive:
Connection could not be established.
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456
 => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\SSTEVENSWIN7PC$'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\SSTEVENSWIN7PC$'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\SSTEVENSWIN7PC$'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\SSTEVENSWIN7PC$'. ) )


Script #2, connect with user name and password - user is set up in SQL Server as Windows Authentication
[code]
<?php
$serverName = "serverName, 1433"; 
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Open in new window


Error Message:
Connection could not be established.
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456
 => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\sstevensProd'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\sstevensProd'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\sstevensProd'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'LC\sstevensProd'. ) )

Gets the right user logon information, but connection still fails.

Script #3:  connect with user name and password, but user is set up for SQL Server Authentication
[code]
<?php
$serverName = "serverName, 1433"; 
$connectionInfo = array( "Database"=>"dbName", "UID"=>"uid", "PWD"=>"pwd");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Open in new window


No errors, connection established.
SueJStevensAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
rinfoConnect With a Mentor Commented:
Have you checked
1.if sqlserver is configured to work in mixed authentication mode.
2.You are logged into correct windows domain properly.
3.It could be UAC make sure you are running as administrator
Besides this there is no reason why windows authentication would fail.
As long as servername and database name is proper.
0
 
Dave BaldwinFixer of ProblemsCommented:
In another question that I can't find right now, someone else said they solved this problem by setting up 'impersonation'.  I don't really know what that means.  The normal PHP/IIS user will never have the permissions by itself.  It is intentionally limited.

In my few pages with SQL Server, I have just used SQL Authentication which only requires username and password.
0
 
SueJStevensAuthor Commented:
I'm not certain my issue is resolved, but closing it anyway.  I was not able to get windows authentication to work but I can get the admin account to work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.