我試圖建立一個連接到我公司的MSSQL服務器與Windows身份驗證,但它失敗,因爲它試圖使用我的計算機名稱作爲登錄而不是我的登錄ID。當與MS SQL Server管理登錄在windows身份驗證工作正常,但與此PHP代碼:PHP試圖用計算機名稱而不是登錄名登錄到MSSQL(Windows身份驗證)
<?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));
}
//
?>
打印輸出我得到的是以下幾點:
[微軟] [SQL Server本機客戶端11.0] [SQL Server] 用戶'xxx \ T2002197 $'登錄失敗。 ))
T2002197是我的電腦名稱,而不是我的登錄ID,所以當然它失敗了。我該如何解決這個問題?我正在使用WAMP。 編輯出一些信息,替換爲'xxx'
是的,但我在SQL服務器上的帳戶只允許使用Windows身份驗證,而不是普通的SQL Server身份驗證。例如,在SQL Server Management Studio中,我只能使用Windows身份驗證登錄,如果嘗試手動輸入我的登錄名/密碼,則失敗。所以我需要使它以某種方式使用Windows身份驗證... – Suedish