PHP尝试使用计算机名而不是登录名登录MSSQL(Windows身份验证)

Sue*_*ish 3 php sql-server-2005

我试图通过Windows身份验证与我公司的MSSQL服务器建立连接,但它失败了,因为它试图使用我的计算机名作为登录而不是我的登录ID.使用MS SQL Server Management登录时,Windows身份验证工作正常,但不能使用此PHP代码:

<?php
// Server in the this format: <computer>\<instance name> or 
// <server>,<port> when using a non default port number
$serverName = "xxx";
$connectionInfo = array( "Database"=>"xxx");

/* Connect using Windows Authentication. */
$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));
}

// 
?>
Run Code Online (Sandbox Code Playgroud)

我得到的打印输出如下:

[Microsoft] [SQL Server Native Client 11.0] [SQL Server]用户'xxx\T2002197 $'登录失败.))

T2002197是我的计算机名,不是我的登录ID,所以它当然失败了.我怎么解决这个问题?我正在使用WAMP.编辑了一些信息,替换为'xxx'

Sue*_*ish 7

Aah问题解决了!我更改了WAMP服务的设置(在Windows中打开service.msc)并确保服务登录到正确的帐户.它现在有效.