Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Display pdf through impersonate does not work
Message
From
11/03/2011 13:10:21
 
 
To
11/03/2011 12:44:33
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01503266
Message ID:
01503376
Views:
18
>>>>>Hello Everybody.
>>>>>
>>>>>I got some problems with impersonation.
>>>>>
>>>>>I have created a asp.net intranet site. The short of it is that the end user gets a grid displayed with pdf files. The pdf files are located on another sever behind locked security to which the enduser has no directly access.
>>>>>
>>>>>When the user clicks on a file in the grid the site should display the pdf file in an embeded pdf viewer on that page. In order to accomplish this i use impersonation in the code-behind secion.
>>>>>Using impersonationContext As New WindowsImpersonationContextFacade()
>>>>>   Me.ShowPdf1.FilePath = c_TempFilePath
>>>>>End Using
>>>>>(Note: this code is used from here with some modifications to fit my purposes. I also know this works because i use the exact same code in a vb.net app to access the same files successfully.)
>>>>>
>>>>>As long as i am testing this (domain admin with rights to that repository) it works fine - so i know the basic loading of the file works. However, for the enduser it does not work. They don't get an error, but the pdf does not display.
>>>>>
>>>>>My assumption is that the file does not actually get loaded in the behind-code but that code only passes the info to the client and the client loads the file.
>>>>>
>>>>>If that is true, that would explain the failure as the client does not have the read right to the repository and the impersonation is already gone.
>>>>>
>>>>>Question:
>>>>>- am i correct with my assumption?
>>>>>- how do I do this correctly?
>>>>>
>>>>>As always - thank you for your great help!
>>>>
>>>>Just glanced at this but it looks as if you are only using impersonation whilst setting a property - not whilst ASP.NET needs to actually access the file ?
>>>
>>>Hello Viv
>>>
>>>Thank you for your reply!
>>>
>>>Thats kinda what i am guessing. when i am looking at the actual code of the .ShowPdf1 object (specific to the FilePath Property)
>>>protected override void RenderContents(HtmlTextWriter
>>>                                       writer)
>>>{
>>>    try
>>>    {
>>>        StringBuilder sb = newStringBuilder();
>>> 
>>>        sb.Append("<iframe src="
>>>                  +FilePath.ToString() + " ");
>>> 
>>>        sb.Append("width=" +
>>>                  Width.ToString() + " height=" + 
>>>                  Height.ToString() + " ");
>>> 
>>>        sb.Append("<View PDF: <a
>>>            href=" + FilePath.ToString() + "</a></p>
>>>            ");
>>> 
>>>        sb.Append("</iframe>");
>>>               
>>>        writer.RenderBeginTag(HtmlTextWriterTag.Div);
>>> 
>>>        writer.Write(sb.ToString());
>>> 
>>>        writer.RenderEndTag();
>>>    }
>>>    catch
>>>    {
>>>               
>>>        // with no properties set, this will render
>>>        // "Display PDF Control" in 
>>>        // a box on the page
>>> 
>>>        writer.RenderBeginTag(HtmlTextWriterTag.Div);
>>> 
>>>        writer.Write("Display PDF Control");
>>> 
>>>        writer.RenderEndTag();     
>>>    }  // end try-catch
>>> 
>>>}   //
Maybe i need to put my impersonation there?
>>>
>>>What do you think?
>>
>>That looks as if it is just embedding the url into the web page - which means the browser will subsequently try to download that from the server.
>>If that's the case what is the value of FilePath at that point ?
>
>by default its just blank. I don't realy see that the code is doing anything with it as a value get asigned.
>
>my i need to create an ebeded viewer myself, where i can tell it to load the page and then enclose that into the impersonation.

One possible solution. Make the .FilePath point to a fixed URL and add a parameter defining the required PDF file so something like Http://myServer/PDFProvider.aspx?somepdfile.pdf
Then in the PDFProvider page use impersonation to open the PDF file and stream it to the Response.OutPutStream. If you set the Response.ContentType to 'Application/pdf' that should work.

It may be possible to somehow stream the pdf file directly into the initial page but, top of my head, I don't know how.....
Previous
Reply
Map
View

Click here to load this message in the networking platform