locked
Crystal Report Viewer prompts for authentication only on the live RRS feed

  • Question

  • User704227388 posted

    I have an asp.net mvc application running an asp page for a Crystal Report Viewer

    When I run the application on my dev server, everything works as expected.

    When I run the application on one live server it opens the viewer, prompts for the user to enter the parameter values, then prompts for the server authentication information.

    When I run it on another liver server it works just like it does in my dev environment.

    All instances are connected to the same SQL Server.

    The server with the issue is Windows Server 2008 R2 Standard. IIS 7.5.7600.16385. The live server that can successfully run the same site is same except it is Datacenter.

    What am I missing?

    Is there an IIS setting that could be causing this issue?

    Thursday, May 2, 2013 5:47 PM

All replies

  • User1815411410 posted

    hi there,

    the issue you experience was caused by the fact that you do not setup full trust mode on your crystal report site. Please make sure you enable LOCAL SERVICE permission on your folder with the READ and WRITE permission.

    For crystal report hosting, you can always check asphostportal.com

    Please mark this response as an "answer" if it helps you. Thanks heaps

    Friday, May 3, 2013 2:55 AM
  • User704227388 posted

    the issue you experience was caused by the fact that you do not setup full trust mode on your crystal report site. Please make sure you enable LOCAL SERVICE permission on your folder with the READ and WRITE permission.

    The folder is within the inetpub/wwwroot/ folder so it should inherit those permissions.  What else would I need to change?  

    The application's folder on the server that works as expected doesn't have any special permissions (including specific access for LOCAL SERVICE).  Additionally, the rest of the application works just fine on the server with issues.  That includes another reporting tool Stimulsoft.

    Is there a way in IIS to block Crystal Reports from accessing a db?  It is just strange that the application can access the SQL SERVER, but Crystal Reports can't

    Friday, May 3, 2013 9:54 AM
  • User1815411410 posted

    even the report is under the inetpub/wwwroot/ folder, have you made sure the READ and WRITE permission are set properly?

    If you want to block your Crystal Report from accessing the DB, you must not specified the connection string. If you do not specify connection string, how can your Crystal Report accesses your DB?

    Please mark this response as an "answer" if it helps you. Thanks heaps 

    Sunday, May 5, 2013 4:20 AM
  • User705563967 posted

    You worte that in one server is working fine but in another server is not working as per my experience is due to database connection string issue . I am sharing the code for database connection string for Crystal report. The main thing in given below code is Table.Location in both for loop e.g dbo.Employee.Name so table locaiton is dbo.Employee try this let me know is working fine or not.

    public static ReportDocument ConnectionInfo(ReportDocument rpt)
            {
    
                try
                {
                    ReportDocument crSubreportDocument;
                    string[] strConnection = ConfigurationManager.ConnectionStrings[("Conn")].ConnectionString.Split(new char[] { ';' });
                    Database oCRDb = rpt.Database;
                    Tables oCRTables = oCRDb.Tables;
                    CrystalDecisions.CrystalReports.Engine.Table oCRTable = default(CrystalDecisions.CrystalReports.Engine.Table);
                    TableLogOnInfo oCRTableLogonInfo = default(CrystalDecisions.Shared.TableLogOnInfo);
                    ConnectionInfo oCRConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
    
                    oCRConnectionInfo.ServerName = strConnection[0].Split(new char[] { '=' }).GetValue(1).ToString();
                    oCRConnectionInfo.Password = strConnection[2].Split(new char[] { '=' }).GetValue(1).ToString();
                    oCRConnectionInfo.UserID = strConnection[1].Split(new char[] { '=' }).GetValue(1).ToString();
    
                    for (int i = 0; i < oCRTables.Count; i++)
                    {
                        oCRTable = oCRTables[i];
                        oCRTableLogonInfo = oCRTable.LogOnInfo;
                        oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo;
                        oCRTable.ApplyLogOnInfo(oCRTableLogonInfo);
                        oCRTable.Location = "dbo" + "." + oCRTable.Location;
                    }
    
                    for (int i = 0; i < rpt.Subreports.Count; i++)
                    {
                        {
                            crSubreportDocument = rpt.OpenSubreport(rpt.Subreports[i].Name);
                            oCRDb = crSubreportDocument.Database;
                            oCRTables = oCRDb.Tables;
                            foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in oCRTables)
                            {
                                oCRTableLogonInfo = aTable.LogOnInfo;
                                oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo;
                                aTable.ApplyLogOnInfo(oCRTableLogonInfo);
                                aTable.Location = "dbo" + "." + aTable.Location;
                            }
    
                        }
    
                    }
    
    
    
                }
                catch (Exception ex)
                {
                   
                }
                return rpt;
    
            }

    Sunday, May 5, 2013 5:00 AM
  • User704227388 posted

    That is what I thought at first, but using the same connection string on a different server, it works perfectly.  The only thing that changed was the server hosting the application.  The db server (and connection string) are the same.  

    I use the same connection string for the rest of the application and that works as expected, so the string has to be good, and the web server has to be able to access the SQL server.  However, for some reason, Crystal isn't able to use that connection string on that one server.

    Monday, May 6, 2013 11:31 AM
  • User704227388 posted

    even the report is under the inetpub/wwwroot/ folder, have you made sure the READ and WRITE permission are set properly?

    If you want to block your Crystal Report from accessing the DB, you must not specified the connection string. If you do not specify connection string, how can your Crystal Report accesses your DB?

    Please mark this response as an "answer" if it helps you. Thanks heaps 

    We did verify that the folder containing the reports has READ and WRITE for EVERYONE.

    Monday, May 6, 2013 11:32 AM
  • User705563967 posted

    try to used my connection string code and deploy then tell me its working fine or not . I know your approach is right but atleast try my connection string code and give table info mendatory.

    Tuesday, May 7, 2013 1:59 AM
  • User704227388 posted

    When I try your method, it doesn't even get the values for the parameters.

    This is how I am presently assigning the login info:

    protected void Page_Load(object sender, EventArgs e)
    {
        ...
        var bc = new Controllers.BaseController();
        var conStr = bc.GetConfigConnStr();
        _rd.SetDatabaseLogon(conStr.UserID, conStr.Password, conStr.DataSource, conStr.InitialCatalog);
    
        foreach (Table tbCurrent in _rd.Database.Tables)
        {
            TableLogOnInfo oLogOn = tbCurrent.LogOnInfo;
            oLogOn.ConnectionInfo.DatabaseName = conStr.InitialCatalog;
            oLogOn.ConnectionInfo.UserID = conStr.UserID;
            oLogOn.ConnectionInfo.Password = conStr.Password;
            oLogOn.ConnectionInfo.ServerName = conStr.DataSource;
            oLogOn.ConnectionInfo.Type = ConnectionInfoType.SQL;
            tbCurrent.ApplyLogOnInfo(oLogOn);
        }
        CrystalReportViewer1.ReportSource = _rd;
        Session.Add("REPORT_KEY", _rd);
        ...
    }

    This is the method in BaseController for GetConfigConnStr

    public SqlConnectionStringBuilder GetConfigConnStr()
    {
        var conStr = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["emanex"].ConnectionString);
        return conStr;
    }

    When I implement your method, I changed it to:

    protected void Page_Load(object sender, EventArgs e)
    {
        ...
        _rd = ConnectionInfo(_rd);
        CrystalReportViewer1.ReportSource = _rd;
        Session.Add("REPORT_KEY", _rd);
        ...
    }




    Tuesday, May 7, 2013 1:49 PM
  • User704227388 posted

    I am not sure why it would be different, but I did notice that strConnection[x] for Password and UserId were pulling the wrong values.  In my connection string I had to use 3 and 2 respecitvely.  

    I suspect that since you're splitting the string that is just because I have them in a different order in the string.

    Tuesday, May 7, 2013 1:54 PM
  • User704227388 posted

    I figured out what was not working with your method:

    These three values weren't getting set like they were in mine

     oLogOn.ConnectionInfo.DatabaseName = conStr.InitialCatalog;
      oLogOn
    .ConnectionInfo.ServerName = conStr.DataSource;
      oLogOn
    .ConnectionInfo.Type = ConnectionInfoType.SQL;

    Once I added these settings to your string, I am able to make it work on my dev server.  Now I will publish to the server with issues and let you know the results.

    Tuesday, May 7, 2013 4:53 PM
  • User704227388 posted

    I get the exact same results on the server with issues as I did before.  Any other ideas?

    Wednesday, May 8, 2013 5:29 PM