我正在使用 SSRS SDK for PHP
PHP 版本 5.4
网络服务器:Centos 6.4
MSSQL 服务器 2008 R2
define("UID", "*****\*****");
define("PASWD", "*****");
define("SERVICE_URL", "http://192.168.0.1/ReportServerURL/");
try {
$ssrs_report = new SSRSReport(new Credentials(UID, PASWD), SERVICE_URL);
} catch (SSRSReportException $serviceException) {
echo $serviceException->GetErrorMessage() . "<br>";
}
当我尝试连接 SSRS 报告时,出现以下错误:
无法连接到报告服务
确保 url (http://192.168.0.1/ReportServerURL/) 和凭据正确!
可以通过浏览器毫无问题地访问相同的凭据和链接。但是,通过 SSRS SDK 它不起作用。
我在网上寻找解决方案,我发现使用文件 TestSSRSConnection.php
我可以获得更多详细信息,但我不知道如何使用它,而且我找不到任何相关文档
$testSSRSConnection = new TestSSRSConnection("/192.168.0.1/TESTREPORT/ReportServerURL/*****\*****/*****");
$testSSRSConnection->Parse();
$testSSRSConnection->TestConnection();
测试它我得到以下错误:
Usage:TestSSRSConnection.php /server: /report: /uid: /pwd: [/datasource: /uid: /pwd:]
关于如何推进这个主题的一些想法?
更新
执行 var_export($http_response_header))
我得到了
array (
0 => 'HTTP/1.1 401 Unauthorized',
1 => 'Content-Length: 0',
2 => 'WWW-Authenticate: Negotiate',
3 => 'WWW-Authenticate: NTLM',
4 => 'Date: Tue, 04 Mar 2014 22:13:58 GMT',
5 => 'Connection: close',
)
最佳答案
问题出在身份验证类型上。
为了获取标题响应,我在第 193 行的 SSRSReport.php 中添加了
if ($content === FALSE) {
throw new SSRSReportException("", "<br>Failed to connect to Reporting Service <br/> Make sure " .
"that the url ($this->_BaseUrl) and credentials are correct!<br>" .
var_export($http_response_header));//Line added by me to get the http header response
}
输出:
array (
0 => 'HTTP/1.1 401 Unauthorized',
1 => 'Content-Length: 0',
2 => 'WWW-Authenticate: Negotiate',
3 => 'WWW-Authenticate: NTLM',
4 => 'Date: Tue, 04 Mar 2014 22:13:58 GMT',
5 => 'Connection: close',
)
Failed to connect to Reporting Service
Make sure that the url (http://192.168.0.1/ReportServerURL/) and credentials are correct!
将基本身份验证添加到 SSRS 解决了这个问题。
配置报表服务器以使用基本身份验证
1- 在文本编辑器中打开 RSReportServer.config。
2- 找到Authentication
。
3- 复制以下最适合您需要的 XML 结构之一。第一个 XML 结构提供了用于指定所有元素的占位符,这将在下一节中进行描述:
<Authentication>
<AuthenticationTypes>
<RSWindowsBasic>
<LogonMethod>3</LogonMethod>
<Realm></Realm>
<DefaultDomain></DefaultDomain>
</RSWindowsBasic>
</AuthenticationTypes>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
如果您使用默认值,您可以复制最小元素结构:
<AuthenticationTypes>
<RSWindowsBasic/>
</AuthenticationTypes>
4- 将其粘贴到 的现有条目上。
如果您使用多种身份验证类型,请仅添加 RSWindowsBasic 元素,但不要删除 RSWindowsNegotiate、RSWindowsNTLM 或 RSWindowsKerberos 的条目。
要支持 Safari 浏览器,您不能将报表服务器配置为使用多种身份验证类型。您必须仅指定 RSWindowsBasic 并删除其他条目。
请注意,您不能将自定义与其他身份验证类型一起使用。
5- 将空值替换为对您的环境有效的值或替换为对您的环境有效的值。
6- 保存文件。
7- 如果您配置了横向扩展部署,请对部署中的其他报表服务器重复这些步骤。
8- 重新启动报表服务器以清除当前打开的所有 session 。
关于php - 无法连接到 PHP 中的 SSRS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22108080/