Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Display pdf through impersonate does not work
Message
From
14/03/2011 12:53:42
 
 
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:
01503611
Views:
38
>>>>>>>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!
>>>>>>
>>>>>>
>>>>>>What does ShowPDF method do?
>>>>>>
>>>>>>If it isn't sending pulling the file as a filestream (or some other mechanism of getting the file to the webserver app) and then presenting the file to the client, your impersonation will make no difference.
>>>>>
>>>>>Hello William
>>>>>
>>>>>Thanks for your reply!
>>>>>
>>>>>The ShowPDF1 is acually an object (bad naming i know :-) ).
>>>>>that object is based on this. Which, If i understood this correctly just passes the full pdf file path/name to the object.
>>>>
>>>>Does anyone know as to how to stream a pdf file to an embeded pdf viewer/reader on a web page?
>>>
>>>I think I just answered this one elsewhere in the thread. If you need more specifics let me know....
>>
>>Thank you!
>>
>>I already started to piece something together based on your idea. Its gonna take me a bit as i am not that familiar with the whole .net, asp, and vb stuff (in case i havn't mentioned that before :-) ) I am just an ol' Fox guy.
>
>If it helps (assuming the .FilePath is set to "PDFProvider.aspx?Somefile.pdf") then in the Page_Load of PDFProvider.aspx:
string fileName = Request.QueryString[0];
>            Response.ContentType = "application/pdf";
>            //Impersonate a user here who has access to the required file
>            string path = RouteToFolderHoldingPDF + fileName;
>            Response.WriteFile(path);
should render Somefile.pdf to the frame.

Hello Viv

That did the trick!

I just changed the Response.WriteFile() to the suggested solution from Microsoft for issues transfering files with 'small' web servers.
Wrapped the hole thing in my Impersonation routine - and jup-dee-doo - works like a charm.

Thank you Viv!
Previous
Reply
Map
View

Click here to load this message in the networking platform