Php-SSRS数据源凭证

时间:2018-07-18 19:17:03

标签: php symfony reporting-services

我在Symfony中使用第三方扩展程序连接到SSRS:https://github.com/ChartBlocks/php-ssrs

我需要保持SSRS数据源为“提示输入凭据”,因为我们还使用了另一种要求该提示的解决方案,但是我不确定如何在解决方案中设置DataSourceCredentials。我收到错误消息:System.Web.Services.Protocols.SoapException:未指定运行报告所需的一个或多个数据源凭据。

这是我在控制器中的代码:

$options = [
    'username' => $this->getParameter('ssrs_user'),
    'password' => $this->getParameter('ssrs_password')
];

$ssrs = new SSRS\Report($this->getParameter('ssrs_server'), $options);
$result = $ssrs->loadReport($this->getParameter('ssrs_base').'/'.$request->get('report'));

$ssrs->setSessionId($result->executionInfo->ExecutionID);
$parameters = json_decode($request->get('parameters'),true);
$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV | HTML4.0 | Excel
return $output;

有人知道我需要添加什么来传递DataSourceCredentials吗?

1 个答案:

答案 0 :(得分:0)

通过在Report.php文件中创建我自己的方法找到答案,直到它在核心中更新为止:

public function setDataSourceCredentials($datasource,$username,$password) {
    $this->checkSessionId();

    $options = array(
        'Credentials' => array(
            'DataSourceCredentials' => array(
                'DataSourceName' => $datasource,
                'UserName' => $username,
                'Password' => $password
            )
        )
    );

    $result = $this->getSoapExecution()->SetExecutionCredentials($options);
    return new ExecutionInfo($result);
}

在呈现报告之前,我在控制器中称呼它为

$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));
$ssrs->setDataSourceCredentials($this->getParameter('ssrs_datasource'),$this->getParameter('ssrs_sql_user'),$this->getParameter('ssrs_sql_password'));