Visual Guard Class Library Documentation

How to secure Crystal Report

To integrate Visual Guard in your WCF Silverlight service you have to:

Referencing Visual Guard assemblies

In order to use Visual Guard, you must add references to Visual Guard assemblies:

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.

Add Visual Guard assemblies

If the assemblies does not appear in this list you can use the Browse tab and select them in the directory <Visual Guard installation directory>/bin/3.1

Description of Visual Guard assemblies:

Adding Visual Guard in your WinForm project

To know how to add Visual Guard in WinForm project see: How to integrate Visual Guard in a WinForm application

 

Adding Visual Guard in your ASP.Net application

To know how to add Visual Guard in ASP.Net project see: How to integrate Visual Guard in ASP.Net Web Site

 

Filter data depend of the connected user login

To filter data in a report Crystal report you have to:

Create a parameter in your report

Create parameter in your report

To create a paremeter in your report:

  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

Choose Field

To filter your report :

  1. Click on "Crystal report/ report/ Select expert",
  2. Select the filed you want to filter,
  3. Click on "Ok",
  4. 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

In your form with the report viewer, create a property.

public string User { get; set; }

 

Intialise the parameter of the report with the property

In your form with the report viewer .

 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. Create Property action
  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. Select expression
  12. Click on "Ok",
  13. Click on "Finish".

Now when you execute your application, the report is filter with the connected user.

Login Form

 

Report

See Also

Debugging Visual Guard Security Actions
How to apply security in your application
How Visual Guard secures an application
How to generate or edit the Visual Guard configuration files
How to integrate Visual Guard in WCF applications