2

I'm trying to programmatically connect to Microsoft SSRS programmatically. I would assume that this would have to be done using the www-authentication http header in some way or another, however I'm not exactly sure.

I'm doing this because I'm having issues with logging into SSRS as an anonymous web user. clients shouldn't be prompted for a username and password.

Assuming I am on the right path, once logged in, the PHP should act as a relay between SSRS as a client (the user browses SSRS through the PHP page).

If there are any other ways to get this working, please shout!

This is how far I've gotten:

<?php
    function get_url_contents($url){
        $crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_VERBOSE, 1);
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_HTTPHEADER,array("WWW-Authenticate: Basic"));
        curl_setopt ($crl, CURLOPT_HEADER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;
    }


    $url = "http://192.168.0.16/ReportServer";
    $str = get_url_contents($url);
    echo $str;
?>

With output being:

C:\wamp\bin\php\php5.3.8>php.exe c:\wamp\www\Test\index.php
* About to connect() to 192.168.0.16 port 80 (#0)
*   Trying 192.168.0.16... * connected
* Connected to 192.168.0.16 (192.168.0.16) port 80 (#0)
> GET /ReportServer HTTP/1.1
Host: 192.168.0.16
Accept: */*
WWW-Authenticate: Basic

< HTTP/1.1 401 Unauthorized
< Content-Length: 0
< WWW-Authenticate: NTLM
< WWW-Authenticate: Basic realm="192.168.0.16"
< Date: Wed, 27 Jun 2012 06:31:24 GMT
<
* Connection #0 to host 192.168.0.16 left intact
HTTP/1.1 401 Unauthorized
Content-Length: 0
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="192.168.0.16"
Date: Wed, 27 Jun 2012 06:31:24 GMT

* Closing connection #0

C:\wamp\bin\php\php5.3.8>
4

1 回答 1

0

因此,如果我没记错的话,SSRS 在开箱即用时“默认”为 NTLM。这意味着它正在寻找一个 Windows AD 帐户。当然,您可以根据您的用例通过配置将这些设置更改为无数其他设置。有关身份验证的更多信息,请查看此页面:http: //msdn.microsoft.com/en-us/library/bb283249.aspx

我很久以前做过一个类似的项目。我们最终使用的最简单的解决方案是创建一个服务帐户,将 PHP 应用程序中使用的各种 SSRS 报告的权限授予服务帐户,然后在 .NET 端创建一个封装 Web 服务,将 SSRS Web 服务称为服务帐户。然后我们从 PHP 端调用这个包装 Web 服务。有关 SSRS Web 服务的信息,请参见此处:http: //msdn.microsoft.com/en-us/library/ms155398.aspx

希望这可以帮助...

于 2012-07-08T04:19:02.447 回答