Author |
Topic |
FCazabon
Starting Member
7 Posts |
Posted - 2011-01-14 : 13:28:59
|
Hi,I'm writing an ASP.NET C# application that makes use of Reporting Services to generate PDFs from the data. I use a command like this to call the report:http://localhost/ReportServer/Pages/Report.aspx?%2fSIAS+Reports%2fReceipt&rs:Command=Render&rs:Format=PDF&rc:Parameters=false&ReceiptNumber=0000000039Which works fine if I put it directly in the browser (although the first time I try it I need to login), but when calling it in my application I get a 403 Forbidden error returned. I guess this means there is some security issue. If I look in the Event Viewer I see this:Event code: 3005Event message: An unhandled exception has occurred.Event time: 01/14/2011 8:00:45 AMEvent time (UTC): 01/14/2011 12:00:45 PMEvent ID: fd216790eada4779be60461c14263d75Event sequence: 14Event occurrence: 1Event detail code: 0Application information:Application domain: /LM/W3SVC/1/ROOT/SIAS-1-129394800055232727Trust level: FullApplication Virtual Path: /SIASApplication Path: C:\SIASMachine name: NEWIMIASDBProcess information:Process ID: 4316Process name: w3wp.exeAccount name: IIS APPPOOL\DefaultAppPoolException information:Exception type: WebExceptionException message: The remote server returned an error: (403) Forbidden.Request information:Request URL: http://localhost/SIAS/ReceiptEdit.aspxRequest path: /SIAS/ReceiptEdit.aspxUser host address: ::1User:Is authenticated: FalseAuthentication Type:Thread account name: IIS APPPOOL\DefaultAppPoolThread information:Thread ID: 5Thread account name: IIS APPPOOL\DefaultAppPoolIs impersonating: FalseStack trace: at System.Net.HttpWebRequest.GetResponse()at SamaanSystems.IAS.Web.ReceiptEdit.btnSave_Click(Object sender, EventArgs e) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Web\ReceiptEdit.aspx.cs:line 420at System.Web.UI.WebControls.Button.OnClick(EventArgs e)at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)Custom event details: So that looks like the DefaultAppPool does not have access to something.If I change the credentials on the request to the administrator login it works.I don't want to hard code a username and password in my code, so what can I do?__Frank |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-01-14 : 17:48:58
|
Use IIS to configure permissions to folders that are required for access. Poor planning on your part does not constitute an emergency on my part. |
|
|
FCazabon
Starting Member
7 Posts |
Posted - 2011-01-17 : 06:51:44
|
Thanks for the response, but I do not see any SSRS folders when running IIS. I have no idea what folders are the ones causing trouble here.__Frank |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-01-17 : 07:36:39
|
Hm, I don't know the answer but I'd try to give the user that's running the asp.net application pool access to the ReportServer database and also IIS access to http://localhost/ReportServer. Been a long time since I worked with IIS...- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
|
|
FCazabon
Starting Member
7 Posts |
Posted - 2011-01-17 : 07:58:41
|
Thanks, but I cannot find localhost\ReportServer in the IIS administration applet. Something changed from SSRS 2005 or 2008 to SSRS 2008 R2 so that IIS no longer displays the ReportManager and ReportServer sites. So any ideas how I can work out what folder and what user (this could be any amount of users) to give access to that folder?__Frank |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-01-17 : 08:18:08
|
..if I could only get my http://localhost/Reports to work... :(How about clicking the "Show details"-link...does it give you any permission options? ->- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-01-17 : 09:37:08
|
For some obscure reason my reportserver just started working, so I was able to browse the site which makes it a little easier. If you click the "Site settings" in the top right corner and then the Security tab you should be able to add the user with proper permissions (I hope...).- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
|
|
FCazabon
Starting Member
7 Posts |
Posted - 2011-01-17 : 11:09:35
|
OK, thanks, I'm getting to the Site Settings, now how do I add the DefaultAppPool user? I get the option add New Role Assignment and try to add that name, but then get an error that DefaultAppPool is not recognized.__Frank |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
|
FCazabon
Starting Member
7 Posts |
Posted - 2011-01-18 : 06:54:27
|
Thanks, that article is very close to what I have been trying. Setting the default credentials is what doesn't work. If I change that to using a a hard coded password it works, but that's not what I want to do.Thanks for your help__Frank |
|
|
ramonal
Starting Member
2 Posts |
Posted - 2012-01-17 : 08:39:39
|
Hi, I have exactly the same problem and it makes me crazy because I can't find the solution!! Did you solve the problem? Could you share it and help me, please? I'm desperate with this problem.Thanks in advance!Ramón. |
|
|
FCazabon
Starting Member
7 Posts |
Posted - 2012-01-17 : 13:29:47
|
Sorry Ramón, it's been so long since I worked on this that I can't remember if I even got a solution. I'll see if I can look at the system again and see what I did. If you don't hear from me by tomorrow, post here again to remind me.__Frank |
|
|
ramonal
Starting Member
2 Posts |
Posted - 2012-01-18 : 06:42:41
|
Thanks a lot FCabazon,I'm looking for a solution for a week and it's making me crazy. If you could help me I'd appreciate it greatly.Thanks again |
|
|
FCazabon
Starting Member
7 Posts |
Posted - 2012-01-19 : 07:08:34
|
Hi again,I looked back at my code and what I do is store a username and password in a settings file and use that to connect.Here's my C# code (hope it helps):string URL = oAppSettings.ReportServerURL + "?/SIAS Reports/Receipt&rs:Command=Render&rs:Format=PDF&rc:Parameters=false&ReceiptNumber=" + this.oReceipt.Entity.ReceiptNumber;System.Net.HttpWebRequest Req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);Req.Credentials = new NetworkCredential(oAppSettings.ReportServerUser, oAppSettings.ReportServerPassword);Req.Method = "GET";//Specify the path for saving.string path = HttpContext.Current.Server.MapPath(@"~/Receipts/") + this.oReceipt.Entity.ReceiptNumber + @".pdf";System.Net.WebResponse objResponse = Req.GetResponse();System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create);System.IO.Stream stream = objResponse.GetResponseStream();byte[] buf = new byte[1024];int len = stream.Read(buf, 0, 1024);while (len > 0){ fs.Write(buf, 0, len); len = stream.Read(buf, 0, 1024);}stream.Close();fs.Close(); __Frank |
|
|
|