【发布时间】:2020-09-26 03:55:52
【问题描述】:
我有一个使用 PHP 7.2 和 SQL Server 2019 开发的应用程序。该应用程序托管在 IIS 10 上。我能够使用 db 的用户名和密码在应用程序和数据库之间建立连接。但是现在我的客户希望我们使用 Windows 身份验证来访问数据库。他们给了我们一个服务名和一个实例名,没有别的。
用于测试连接的代码是
<?php
$serverName = "DEV1ECLD001A\FEB19M"; //serverName\instanceName
$connectionInfo = array( "Database"=>"ECLIPSE");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
try {
if( $conn ) {
echo "Connection established.<br />";
}else{
//throw new Exception('Unable to connect');
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
}catch(Exception $e) {
echo '{"error":{"text":'. $e->getMessage() .'}}';
}
?>
``````````
In php.ini, added the lines below
fastcgi.impersonate = 0
mssql.secure_connection = On
In IIS sever,
Anonymous Authentication = Disabled
Windows Authentication = Enabled
My DB and UI are in 2 different servers and I am able to ping both and access the DB if username and password are given but not through windows auth.
While trying to connect, get this error below:
Connection Could not be established. Login failed for user prod/DEV1ECLD001A$
Am I overlooking something ? Kindly help to resolve.
【问题讨论】:
-
你有什么解决办法吗?
标签: php sql laravel windows authentication