Reputation: 237
I am using two different application(Application A and Application B) which are hosted in two different server. Application A is normal user application and application B is used for viewing the SSRS report only.
Now, in Application A I have one page and inside that I have embedded the URL of application B inside iframe which will load the report in iframe based on the URL parameters.
This application B is highly secured and allow only one user(let's say user is surendra). So if application A is accessed within different machine than credentials of that machine will be passed as a network credential to application A for getting particular report to load. But application B allows only specific user so it will through access denied error.
The application B is not allowed to change user access or change any code. Is there any way to solve this issue?
Is there any way like i will be able to pass special credentials (user surendra) while iframe request url of application B so that access be granted and any user can see that report, there is no dependency on user's machine.
I can store this credentials inside configuration details of application A and use them to get the report only from application B.
Please let me know any other work around.
Upvotes: 1
Views: 590
Reputation: 1275
The iframe cannot pass specific credential other than passing paremeters in query string. A solution is to have the iframe request an action in Application A, within the action you could use the needed network credential(surendra) to request report from B, and then return the result to iframe.
E.g. The change the iframe in Application A:
<iframe src="@Url.Action("GetReport", "Home", new { reportUrl = "http://applicationB/report/parameters" })"></iframe>
Then add an Action in Application A to get report from B, using needed credential. like:
public ActionResult GetReport(string reportUrl)
{
Uri uri = new Uri(reportUrl);
var request = WebRequest.CreateHttp(uri );
//use specific credential to retrieve report
request.Credentials = new NetworkCredential("surendra", "pwd", "domain");
var response = request.GetResponse();
using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
{
var html = sr.ReadToEnd();
//add <base> tag in the header so that the resources resolve at the base of the target domain
var baseTag = string.Format("<base href='{0}://{1}'> ", uri.Scheme, uri.Host);
html = html.Insert(html.IndexOf("<head>", StringComparison.InvariantCultureIgnoreCase) + 6, baseTag);
return Content(html);
}
}
Upvotes: 2