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>

1 Answers1

0

So if I remember correctly, SSRS "defaults" to NTLM when installed out of the box. Meaning it's looking for a Windows AD account. Of course you can change these settings via a config to a myriad of other settings according to your use case. For more information on authentication, check out this page: http://msdn.microsoft.com/en-us/library/bb283249.aspx

I worked on a project similar to this a long time ago. The easiest solution that we ended up using was creating a service account, granting rights to the various SSRS reports used in the PHP application to the service account, then creating essentially a wrapper web service on the .NET side that called the SSRS web services as the service account. Then we called this wrapper web service from the PHP side. For information on the SSRS web services see here: http://msdn.microsoft.com/en-us/library/ms155398.aspx

Hope this helps...

Tolowe
  • 91
  • 4