Click here to Skip to main content
14,241,514 members
Rate this:
Please Sign up or sign in to vote.
I am working an EPR where I need to create and download the crystal report as pdf in share folder "\\org\erp_tst" .But it is working fine in local(IIS) .But when I migrate the whole development to dev it comes up with exception .

I checked the erp_tst folder security and it says only 4-6 get the access to write here.
I want to use shareusername ,sharepassword for the specific operation. Tried some of it but didn't work in dev. It you have any idea please share .

Error on Dev:-
rror downloading the fileSystem.UnauthorizedAccessException: Access to the path '\\org\erp_tst\mypay.pdf' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at CrystalDecisions.CrystalReports.Engine.FormatEngine.WriteStreamToFile(Stream stream, String filename) at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportStreamToFile(Stream stream, DiskFileDestinationOptions options) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName) at EFS.arbitration.b_printpdf_click(Object sender, EventArgs e)


What I have tried:

string shareuser = "user1"; // share user name
    string sharepass = "My444"; //share password

    rptArb1.SetDatabaseLogon(shareuser, sharepass);


rptArb1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"share path" + OutputFileName);
Posted
Comments
F-ES Sitecore 1-May-19 11:20am
   
You'll need to change the account IIS executes your code under to one that can access the share. Google for how to change the IIS anonymous account, it varies depending on your version of IIS.
SRoy_5 1-May-19 11:33am
   
thanks for the reply! but the application is running in Windows server 2012 and I don't have privilege to change it.
Also I want to use the share user id and password for security. Is there any way I can use the specific shareuser credential cause the share path is internal.
F-ES Sitecore 1-May-19 11:59am
   
It's configured like that for security reasons, so you don't upload code to a server that then remotely accesses other machines. I doubt you'll get the code you have now working without changing the IIS user. A potential solution might be to impersonate a valid user that has access programatically rather than via IIS config. Try something like the below

https://support.microsoft.com/en-us/help/306158/how-to-implement-impersonation-in-an-asp-net-application
SRoy_5 1-May-19 12:24pm
   
thanks F-ES Sitecore! let me try the impersonation in my EFS.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100