Showing posts with label reports. Show all posts
Showing posts with label reports. Show all posts

Saturday, March 24, 2012

Permission Problem writing to Disk in Asp.NET application

Here's what I need to do:
Due to a bug in Crystal Reports ExportToStream() method I can't stream a
Crystal Reports directly to the client as PDF and I must must use the
Export() and put the the PDF on disk first and stream to the client. That's
just how it is.

Question:
So I need to let the aspx user have write permissions to disk.. NOT GOOD.
How do I solve this? Can I somehow write the PDF to disk in another thread
with other writes? OR are ther other ways around this?

best regards
/Lars NetzelLars

Note : The code below is stripped from a asp.net project using a web
service. This project would relay a binary file from an internal web server
where Crystal reports is installed to an external web server. You will still
need write permissions for the directory you want to save to

You could try this, I hope It helps

Stream fs =
rep.ExportToStream(CrystalDecisions.Shared.ExportF ormatType.PortableDocFormat);
byte[] binaryfile = StreamToBinary(fs);
string docLocation = Server.MapPath(null) + @."\Docs\";
SaveFileToServer(binaryfile,docLocation,"my.pdf",DateTime.Now);
Response.Redirect("Docs/"+"my.pdf");

public void SaveFileToServer(byte[] binaryFile, string docPath, string
docName, DateTime fileModifiedDate)
{
Directory.CreateDirectory(docPath);
MemoryStream m = new MemoryStream(binaryFile);
FileStream f = new FileStream(docPath+docName,FileMode.Create);
m.WriteTo(f);
f.Close();
m.Close();
File.SetLastWriteTime(docPath+docName,fileModified Date);
}

public byte[] StreamToBinary(Stream fs)
{
Int32 i = Convert.ToInt32(fs.Length);
byte[] b = new byte[fs.Length];
fs.Read(b,0,i);
fs.Close();
}

"Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
> Here's what I need to do:
> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
> Crystal Reports directly to the client as PDF and I must must use the
> Export() and put the the PDF on disk first and stream to the client.
> That's just how it is.
> Question:
> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
> How do I solve this? Can I somehow write the PDF to disk in another thread
> with other writes? OR are ther other ways around this?
> best regards
> /Lars Netzel
Thanks but I can't ExportToStream due to a bug with record and
groupselections in the Crystal Reports Engine. so I can't use that code.

I need to write to disk with other permisisons than the ASPNET user

/Lars

"Kamal Vaghjiani" <kamal@.mortgageuk.com> wrote in message
news:Ok7aI59HFHA.2784@.TK2MSFTNGP09.phx.gbl...
> Lars
> Note : The code below is stripped from a asp.net project using a web
> service. This project would relay a binary file from an internal web
> server where Crystal reports is installed to an external web server. You
> will still need write permissions for the directory you want to save to
> You could try this, I hope It helps
> Stream fs =
> rep.ExportToStream(CrystalDecisions.Shared.ExportF ormatType.PortableDocFormat);
> byte[] binaryfile = StreamToBinary(fs);
> string docLocation = Server.MapPath(null) + @."\Docs\";
> SaveFileToServer(binaryfile,docLocation,"my.pdf",DateTime.Now);
> Response.Redirect("Docs/"+"my.pdf");
> public void SaveFileToServer(byte[] binaryFile, string docPath, string
> docName, DateTime fileModifiedDate)
> {
> Directory.CreateDirectory(docPath);
> MemoryStream m = new MemoryStream(binaryFile);
> FileStream f = new FileStream(docPath+docName,FileMode.Create);
> m.WriteTo(f);
> f.Close();
> m.Close();
> File.SetLastWriteTime(docPath+docName,fileModified Date);
> }
> public byte[] StreamToBinary(Stream fs)
> {
> Int32 i = Convert.ToInt32(fs.Length);
> byte[] b = new byte[fs.Length];
> fs.Read(b,0,i);
> fs.Close();
> }
>
> "Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
> news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
>> Here's what I need to do:
>> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
>> Crystal Reports directly to the client as PDF and I must must use the
>> Export() and put the the PDF on disk first and stream to the client.
>> That's just how it is.
>>
>> Question:
>> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
>> How do I solve this? Can I somehow write the PDF to disk in another
>> thread with other writes? OR are ther other ways around this?
>>
>> best regards
>> /Lars Netzel
>>

Permission Problem writing to Disk in Asp.NET application

Here's what I need to do:
Due to a bug in Crystal Reports ExportToStream() method I can't stream a
Crystal Reports directly to the client as PDF and I must must use the
Export() and put the the PDF on disk first and stream to the client. That's
just how it is.
Question:
So I need to let the aspx user have write permissions to disk.. NOT GOOD.
How do I solve this? Can I somehow write the PDF to disk in another thread
with other writes? OR are ther other ways around this?
best regards
/Lars NetzelLars
Note : The code below is stripped from a asp.net project using a web
service. This project would relay a binary file from an internal web server
where Crystal reports is installed to an external web server. You will still
need write permissions for the directory you want to save to
You could try this, I hope It helps
Stream fs =
rep.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocForma
t);
byte[] binaryfile = StreamToBinary(fs);
string docLocation = Server.MapPath(null) + @."\Docs\";
SaveFileToServer(binaryfile,docLocation,
"my.pdf",DateTime.Now);
Response.Redirect("Docs/"+"my.pdf");
public void SaveFileToServer(byte[] binaryFile, string docPath, string
docName, DateTime fileModifiedDate)
{
Directory.CreateDirectory(docPath);
MemoryStream m = new MemoryStream(binaryFile);
FileStream f = new FileStream(docPath+docName,FileMode.Create);
m.WriteTo(f);
f.Close();
m.Close();
File. SetLastWriteTime(docPath+docName,fileMod
ifiedDate);
}
public byte[] StreamToBinary(Stream fs)
{
Int32 i = Convert.ToInt32(fs.Length);
byte[] b = new byte[fs.Length];
fs.Read(b,0,i);
fs.Close();
}
"Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
> Here's what I need to do:
> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
> Crystal Reports directly to the client as PDF and I must must use the
> Export() and put the the PDF on disk first and stream to the client.
> That's just how it is.
> Question:
> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
> How do I solve this? Can I somehow write the PDF to disk in another thread
> with other writes? OR are ther other ways around this?
> best regards
> /Lars Netzel
>
Thanks but I can't ExportToStream due to a bug with record and
groupselections in the Crystal Reports Engine. so I can't use that code.
I need to write to disk with other permisisons than the ASPNET user
/Lars
"Kamal Vaghjiani" <kamal@.mortgageuk.com> wrote in message
news:Ok7aI59HFHA.2784@.TK2MSFTNGP09.phx.gbl...
> Lars
> Note : The code below is stripped from a asp.net project using a web
> service. This project would relay a binary file from an internal web
> server where Crystal reports is installed to an external web server. You
> will still need write permissions for the directory you want to save to
> You could try this, I hope It helps
> Stream fs =
> rep.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFor
mat);
> byte[] binaryfile = StreamToBinary(fs);
> string docLocation = Server.MapPath(null) + @."\Docs\";
> SaveFileToServer(binaryfile,docLocation,
"my.pdf",DateTime.Now);
> Response.Redirect("Docs/"+"my.pdf");
> public void SaveFileToServer(byte[] binaryFile, string docPath, string
> docName, DateTime fileModifiedDate)
> {
> Directory.CreateDirectory(docPath);
> MemoryStream m = new MemoryStream(binaryFile);
> FileStream f = new FileStream(docPath+docName,FileMode.Create);
> m.WriteTo(f);
> f.Close();
> m.Close();
> File. SetLastWriteTime(docPath+docName,fileMod
ifiedDate);
> }
> public byte[] StreamToBinary(Stream fs)
> {
> Int32 i = Convert.ToInt32(fs.Length);
> byte[] b = new byte[fs.Length];
> fs.Read(b,0,i);
> fs.Close();
> }
>
> "Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
> news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
>

Wednesday, March 21, 2012

Permissions on local net

I am creating a local intranet site to use for reporting and other tasks. Some reports should only be accessed by certain people. We are using a Windows 2003 based network. I'd like users to be able to use the site with their same login credentials. (ie if a user logs in to their computer as joe schmoe, I would like them to access the website as joe schmoe without any further login prompts.

Is this possible and/or how do I set this up? I've been playing around with the IIS settings and I cant seem to get it right, it seem to access files and such as the ASPNET user. Is there some setting I should have in the web.config file?

For now, the IIS is version 5.0 because it's ran in a Windows 2000 server...would it be eaiser to move the site to an IIS 6.0 server?If you're using a domain, the recommended way to do this is by using Windows Authentication (in the web.config file you can specify this by means of the <authentication mode="Windows" /> setting). Furthermore, if you want the files on the file system to be access under the context of the logged in user you'll need to enable impersonation (<impersonation enabled="true" />). To get this to work, you webserver should be at least a member server in the domain. However, I'd recommend to move to IIS 6 if you can for better ASP.NET integration and better security/performance.
With this, I get a configuration error:

Parser Error Message: Unrecognized configuration section 'impersonation'
Line 48: <impersonation enabled="true" /
Did you mean:
<identity impersonate="true" />
instead?

I have it set up with <identity impersonate="true" /> and in IIS, Anonymous access is unchecked along with everything else except Integrated Windows authentication.

However, when I attempt to create a file on a network share I get a prompt for a username and password even though the account I'm logged in as has administrator permission and full control over that share. the only way I can continue from this prompt is by enterent the full domain/username and password.

Both the server and client are members of the domain (we're in a single domain environment)