Friday, February 17, 2012

Display IP address from client in a report

I know that may seem like a weird request, but bear with me. I have multiple possible web sites that would request a report from a given Report Server, and I'd like the IP address of whatever machine requested the report to be displayed somewhere on said report. Is there a way to achieve this?

Thank you!

NOTE: To simplify things, I literally want to display whatever IP the reporting server sees. No need to think complicated about if its a server, a client, etc. Just whatever IP the report server is seeing.

You can use a parameter in query string that contain IP address of the server macchine that require the report.

|||

You can get a client's IP address by:

string GetIPAddress(){return HttpContext.Current.Request.UserHostAddress;}

You can put this code in a custom assembly. You can call this assembly in your report:http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx

|||

I thought about embedding code, but unfortunately, the Request object is not set in a report (had to import System.web in it first to test that).

And sending the IP as a parameter would be the easy way, with a catch: Servers tend to have a lot of IPs, even more so if you include the IPv6 ones. Its difficult to "guess" which one is exposed to the server. Can do some tricks using subnet masks and such, but the ideal would be for the server to find it, itself.

My plan B is to have a config in machine.config or something (multiple apps need it, not just web) with the IP as a key, and we'll have to make sure not to forget to change it, or something...

No comments:

Post a Comment