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>