I have a PHP server running under IIS on serverIIS1, and a MS SQL database on serverDB4. I created some PHP code that runs on the serverIIS1 server:

$serverName = "serverDB4\serverDB4";
$connectionInfo = array( "Database"=>"DATABASE_NAME", "UID"=>"DOMAIN.ORG\\databaseadm", "PWD"=>"passwordishere");

$conn = sqlsrv_connect( $serverName, $connectionInfo);

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

I verified all this info is correct (the login is a Windows account with proper access, so it's via Windows authentication), but I'm getting this error:

Login failed for user 'DOMAIN.ORG\databaseadm'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN.ORG\databaseadm'. )

Why is the login failing? I know the info is right, as I can connect manually remotely via SQL Server Management Studio with those details.

Is it because I'm using Windows authentication? If that does not allow plaintext auth, how can I sqlsrv_connect with a Windows password?

1 Answer 1


As stated in the documentation you do not pass the UID and PWD to utilize Windows Authentication. You can see an example here.

From remarks within documentation link:

If values for the UID and PWD keys are not specified in the optional $connectionInfo parameter, the connection will be attempted using Windows Authentication. For more information about connecting to the server, see How to: Connect Using Windows Authentication and How to: Connect Using SQL Server Authentication.

  • Yes that's what I started thinking. How can I authenticate with this specific Windows account, since the Windows account that IIS runs under does not have access to the database?
    – JBurace
    Commented Oct 16, 2014 at 20:09
  • You configure that within your site in IIS and believe it is the identity configured for the application pool.
    – user507
    Commented Oct 16, 2014 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.