Integrated Security


Is there a way to use Integrated Security when displaying a Crystal Report from within a .NET application   I'm currently using the below code, but would prefer to not hardcode a username/password into the application.  Thanks for your help.

sean



'Setup the connection information structure to be used

'to log onto the datasource for the report.

crConnectionInfo = New ConnectionInfo

With crConnectionInfo

.ServerName = "server" 'physical server name

.DatabaseName = "database"

.UserID = "username"

.Password = "pwd"

End With



Answer this question

Integrated Security

  • Cristiano Muzi

    I have to switch my applications over to integrated security. I cant seem to get the integrated security to work. Do you have to enable Single Sign-on API Support

    some where Is this a service

    EXIST WAY (WORKS):

    rcDoc = new ReportClientDocument();

    object path = "AddsRpt/" + ((cSessionTemplate)Session["SessionRec"]).RptName + ".rpt";

    rcDoc.Open(ref path, 1);

    ConnectionInfo rcConnectionInfo = rcDoc.DatabaseController.GetConnectionInfos(null)[0].Clone(true);

    rcConnectionInfo.UserName = ((cSessionTemplate)Session["SessionRec"]).DBLogin;

    rcConnectionInfo.Password = ((cSessionTemplate)Session["SessionRec"]).DBPassword;

    PropertyBag rcAttributes = rcConnectionInfo.Attributes;

    PropertyBag rcLogonInfo = (PropertyBag)rcAttributes["QE_LogonProperties"];

    rcLogonInfo["Data Source"] = ((cSessionTemplate)Session["SessionRec"]).ServerName;

    rcLogonInfo["Initial Catalog"] = "addsrpt";

    CrystalDecisions.ReportAppServer.DataDefModel.Table rcTableOld = (CrystalDecisions.ReportAppServer.DataDefModel.Table)rcDoc.Database.Tables[0];

    CrystalDecisions.ReportAppServer.DataDefModel.Table rcTableNew = new CrystalDecisions.ReportAppServer.DataDefModel.Table();

    rcTableNew.Name = rcTableOld.Name;

    rcTableNew.ConnectionInfo = rcConnectionInfo;

    rcDoc.DatabaseController.SetTableLocation(rcTableOld, rcTableNew);

    PassParameter(0,((cSessionTemplate) Session["SessionRec"]).CtlHierarchy);

    PassParameter(1,((cSessionTemplate) Session["SessionRec"]).RptType);

    PassParameter(2,((cSessionTemplate) Session["SessionRec"]).Bien.ToString());

    PassParameter(3,((cSessionTemplate) Session["SessionRec"]).Month.ToString());

    CHANGED it by commenting out the connection info:

    rcDoc = new ReportClientDocument();

    object path = "AddsRpt/" + ((cSessionTemplate)Session["SessionRec"]).RptName + ".rpt";

    rcDoc.Open(ref path, 1);

    //ConnectionInfo rcConnectionInfo = rcDoc.DatabaseController.GetConnectionInfos(null)[0].Clone(true);

    //rcConnectionInfo.UserName = ((cSessionTemplate)Session["SessionRec"]).DBLogin;

    //rcConnectionInfo.Password = ((cSessionTemplate)Session["SessionRec"]).DBPassword;

    //PropertyBag rcAttributes = rcConnectionInfo.Attributes;

    //PropertyBag rcLogonInfo = (PropertyBag)rcAttributes["QE_LogonProperties"];

    //rcLogonInfo["Data Source"] = ((cSessionTemplate)Session["SessionRec"]).ServerName;

    //rcLogonInfo["Initial Catalog"] = "addsrpt";

    //CrystalDecisions.ReportAppServer.DataDefModel.Table rcTableOld = (CrystalDecisions.ReportAppServer.DataDefModel.Table)rcDoc.Database.Tables[0];

    //CrystalDecisions.ReportAppServer.DataDefModel.Table rcTableNew = new CrystalDecisions.ReportAppServer.DataDefModel.Table();

    //rcTableNew.Name = rcTableOld.Name;

    //rcTableNew.ConnectionInfo = rcConnectionInfo;

    //rcDoc.DatabaseController.SetTableLocation(rcTableOld, rcTableNew);

    PassParameter(0,((cSessionTemplate) Session["SessionRec"]).CtlHierarchy);

    PassParameter(1,((cSessionTemplate) Session["SessionRec"]).RptType);

    PassParameter(2,((cSessionTemplate) Session["SessionRec"]).Bien.ToString());

    PassParameter(3,((cSessionTemplate) Session["SessionRec"]).Month.ToString());

    I get the following error:

    Server Error in '/ADDSReporter' Application.

  • JensLundberg

    Hello Sean,

    It looks like you have the integrated security working.  I believe that you can comment out the crConnectionInfo stuff as well.

    You should test it out by logging into the machine with a user that does not have rights to the database.

    Keith - Business Objects

  • Marcin Obel

    Hello Sean,

    This is a new feature just introduced with Crystal Reports XI, from the help file:

    Single Sign-on API Support.
    Single Sign-on uses a single trusted authentication to grant access to multiple trusted resources. Use of Single Sign-on limits the frequency that passwords are passed across the network, thereby improving network security.

    In Crystal Reports XI, developers can create Winform or Webform applications that can pass trusted authentication security credentials through to the SQL Server database. This allows a mixed-mode scenario where the report can be designed against a SQL-Server authenticated datasource, yet at runtime be accessed with a Single Sign-on trusted authentication, such as Active Directory.

    http://www.businessobjects.com/global/pdf/products//crystalreports/crxi_feat_ver_ed.pdf

    You can also check it out on page 4 of the feature list comparison.

    Keith - Business Objects



  • Miketrix

    It looks like I got Integrated Security working.  I commented out the code above, just leaving the portion...

    crConnectionInfo = New ConnectionInfo

    and then setup the ODBC datasources on the machine to use Integrated Windows Security.  The report still runs fine, and no hard coded username/passwords.

    Am I missing something, or is it actually using the integrated security from the DSN now   Thanks.


    sean


  • Integrated Security