How to secure Crystal Report ?

Author: admin 70 views

To integrate Visual Guard in your application you have to:

  • Add the assemblies of Visual Guard as references of your project.
  • Integrate Visual Guard in the code of your application.
  • Create a Visual Guard repository and declare your application by using the
    Visual Guard console. This repository will contain all security items (users,
    roles, permissions …) of your application.
  • Generate the Visual Guard configuration
    files by using the Visual Guard console. These configuration files will be
    needed to connect your application to the repository.
  • Grant read/write permissions to the repository.


Referencing Visual Guard assemblies

  • Opens the solution of your project in Visual Studio.
  • In the solution explorer, expands the project node.
  • Right-click the Project node for the project and select
    Add Reference

    from the shortcut menu.
  • In .Net tab, select the 4 assemblies
    1. Novalys.VisualGuard.Security
    2. Novalys.VisualGuard.Security.<ProjectType> (WinForm,
      ASP.net),
    3. Novalys.VisualGuard.Security.<RepositoryType> (Files, SQLServer or Oracle)
    4. Novalys.VisualGuard.Security.<ApplicationFrameworkType> (Depending on type of application’s framework, whether .NetFramework or .NetCore)

    And, then click the Select button, and then click the OK button

Note Note
In the list of assemblies, Visual Studio can display different
versions of the Visual Guard assemblies. You must select the assembly
corresponding to the version of the framework used in your project.

Note Note
You must add either Novalys.VisualGuard.Security.NetFramework or Novalys.VisualGuard.Security.Core (Depending on type of application’s framework)

Add References

  • Novalys.VisualGuard.Security contains the main Visual Guard classes.
  • Novalys.VisualGuard.Security.Files contains the classes needed to access
    to a file based repository.
  • Novalys.VisualGuard.Security.SQLServer contains the classes
    needed to access to a repository stored in a Microsoft SQLServer database
    (SQLServer 2000 or higher). Available only in Visual Guard Enterprise Edition
  • Novalys.VisualGuard.Security.Oracle
    contains the classes needed to access to a repository stored in an Oracle
    database (8i or higher). Available only in Visual Guard Enterprise Edition
  • Novalys.VisualGuard.Security.WebForm contains the classes
    needed to ASP.Net application. You must reference this assembly in ASP.Net
    WebSite or ASP.Net WebService project.
  • Novalys.VisualGuard.Security.WinForm contains all classes based on WinForm
    control. This assembly is needed only if you use the forms provided by Visual
    Guard to authenticate, change a password or select a role. If you want to use
    your own form you do not need to add a reference to this assembly.
  • Novalys.VisualGuard.Security.NetFramework contains all classes required to support .Net Framework applications.
    This assembly is needed only if you want to integrate Visual Guard in .net framework applications.
  • Novalys.VisualGuard.Security.Core contains all classes required to support .Net Core applications.
    This assembly is needed only if you want to integrate Visual Guard in .net core applications.


Adding Visual Guard in your WinForm project


Adding Visual Guard in your ASP.Net application


Filter data depend of the connected user login

  • Create parameters in your report,
  • Filter data with the parameter in your report,
  • Create a property to initialise your user name,
  • Intialise the parameter of the report with the property,
  • Create a permissions in Visual Guard.

Create a parameter in your report

Crystal Report Param

  1. Open the report,
  2. Right click in “Parameters Fileds”,
  3. Click on “New”,
  4. Enter “Parameter name”, “Description” and select “Value Type”,
  5. Select “Discrete Value”,
  6. Click on “Ok”.

Filter data with the parameter in your report

Crystal Report Choose Field

  1. Click on “Crystal report/ report/ Select expert”,
  2. Select the filed you want to filter,
  3. Click on “Ok”,
  4. Crystal Report Select Expert
  5. In your select field, select “is equal to”,
  6. In the drop dow list on the right select the parameter,
  7. Click on “Ok”.

Create a property to initialise your user name

public string User { get; set; }

Intialise the parameter of the report with the property

private void Form1_Load(object sender, EventArgs e)
{
    SqlConnection SQLCon = new SqlConnection(Properties.Settings.Default.visualguarddb_NBAConnectionString);
    try
    {    

        SQLCon.Open();

        DSVG ds = new DSVG();
                                SqlDataAdapter ada = new SqlDataAdapter("select * from VG_Log", SQLCon);
        ada.Fill(ds, "VG_Log");


        //Create a parameter
        ParameterFields pfields = new ParameterFields();
        ParameterField pfield = new .ParameterField(); 
        ParameterDiscreteValue disvalue = new ParameterDiscreteValue();


        // Parameter Name 
        pfield.Name = "UserName"; 

        // Iniatialise the Parameter Value 
        disvalue.Value = User;/initialise the parameter with the valuean>
        pfield.CurrentValues.Add(disvalue);

        //Add the parameter in the list of parameters
        pfields.Add(pfield);

        //Add the parameters list in the ParameterFieldInfo of the report viewer
        crystalReportViewer1.ParameterFieldInfo = pfields;

        vgEventReport.SetDataSource(ds);

        crystalReportViewer1.ReportSource = vgEventReport; 

    }
    catch (Exception)
    {
        throw;
    }
    finally
    {    
        SQLCon.Close();
    }
}


Create a permissions in Visual Guard

  1. Open Visual Guard Console,
  2. Select your application,
  3. Create a new Permission (cf: Create a new Permission in the
    documentation “Visual Guard Win Console”),
  4. Create a new Argument on the permission (cf: Edit Argument list
    in the documentaion “Visual Guard Win Console”),
  5. Create a property action (cf:Properties actions in the
    documentation “Visual Guard Console”),
  6. Crystal Report Argument
  7. Select the form where you create the property,
  8. Select your property in the property grid (user),
  9. Click on “add Expression”,
  10. Select ” Current UserName”,
  11. Crystal Report Expression
  12. Click on “Ok”,
  13. Click on “Finish”.

Crystal Report Login

Crystal Report