Saturday, February 25, 2012

Report Server access via WebClient / HttpWebRequest

Hi,
This is a follow-up question I have to a previous post about accessing the
Reporting Services server without exposing a URL to the user that can be
tampered with.
I am using WebClient / HttpWebRequest to screen scrape a server-side
initiated request to the Reporting Service and writing the output into an
ASPX page. This works to a certain extent.
Unfortunately, when the ASPX page initiates the call, all relative URLs are
not correctly processed. For example, the usual address of the report server
might be http://brensydsql/ReportServer however, using a WebClient /
HttpWebRequest will use the hostname of the machine it's on, so relative URLs
will be relative to the local hostname instead of the report server's
hostname.
ie /images/blah.jpg would resolve as http://hostname/images/blah.jpg instead
of http://brensydsql/images/blah.jpg
Adding a <base href='http://brensydsql'> doesn't work either because Sql
Reporting services resources are only accessible during the request
processing and cannot be directly linked after the request has finished. The
Reporting Server needs to be fooled into thinking the root server is
brensydsql when the request is first initiated.
For some reason, after the report has been processed, the fully qualified
url to the image / whatever resource is no longer valid - seems like it is
only valid for the duration of the request?
I've tried to set the BaseAddress property of the WebClient object but this
has no effect.I have been looking at the same problem. I can't believe Microsoft
decided to pass the parameters unencrypted. Surely they must have
realised developers would need to have hidden and secured params.
Anyway, I digress.
Try using regular expressions to alter all of the links in the report.
The basics of this is here:
http://www.junto.co.uk/Diary/2005/10/6363e490-89a1-4f22-b811-d8d82c98acc9.aspx
Hope this helped.
Philip York wrote:
> Hi,
> This is a follow-up question I have to a previous post about accessing the
> Reporting Services server without exposing a URL to the user that can be
> tampered with.
> I am using WebClient / HttpWebRequest to screen scrape a server-side
> initiated request to the Reporting Service and writing the output into an
> ASPX page. This works to a certain extent.
> Unfortunately, when the ASPX page initiates the call, all relative URLs are
> not correctly processed. For example, the usual address of the report server
> might be http://brensydsql/ReportServer however, using a WebClient /
> HttpWebRequest will use the hostname of the machine it's on, so relative URLs
> will be relative to the local hostname instead of the report server's
> hostname.
> ie /images/blah.jpg would resolve as http://hostname/images/blah.jpg instead
> of http://brensydsql/images/blah.jpg
> Adding a <base href='http://brensydsql'> doesn't work either because Sql
> Reporting services resources are only accessible during the request
> processing and cannot be directly linked after the request has finished. The
> Reporting Server needs to be fooled into thinking the root server is
> brensydsql when the request is first initiated.
> For some reason, after the report has been processed, the fully qualified
> url to the image / whatever resource is no longer valid - seems like it is
> only valid for the duration of the request?
> I've tried to set the BaseAddress property of the WebClient object but this
> has no effect.

No comments:

Post a Comment