我試圖以編程方式以編程方式連接到Microsoft SSRS。我會假設這將不得不使用www-authentication http頭以某種方式完成,但是我並不確定。以編程方式登錄到SSRS
我這樣做是因爲我在作爲匿名Web用戶登錄到SSRS時遇到問題。不應提示客戶輸入用戶名和密碼。
假設我在正確的路徑上,一旦登錄,PHP應該充當SSRS作爲客戶端(用戶通過PHP頁面瀏覽SSRS)之間的中繼。
如果還有其他方法可以使這個工作,請大喊!
這是多遠,我已經得到了:
<?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;
?>
具有輸出感:
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>