ActiveReports 12 Server User Guide
Custom Security Provider Sample
ActiveReports 12 Server User Guide > Samples and Walkthroughs > Samples > Custom Security Provider Sample

The ActiveReports Server installation includes a security provider sample that you can find in:

C:\ActiveReports 12 Server\SDK\Samples\ActiveTunes.SecurityProvider

To open the solution, double-click the ActiveTunes.SecurityProvider.sln file.

This sample comes with an SQLite database (ActiveTunes.sqlite), which has Customer and Employee tables. The sample demonstrates how you can log in to ActiveReports Server with the user information saved in those tables and use row-level security.

Note: By default, users from the Customer table have the ActiveTunesCustomer role and users from the Employee table have the ActiveTunesEmployee role. To enable the setting, you should create the ActiveTunesCustomer and ActiveTunesEmployee roles on the Administrator Dashboard in advance.

To compile and use the Security Provider sample

  1. With the sample open in Visual Studio, from the Build menu, select Build Solution.

    If Nuget Package Manager extension version 2.7 or above is installed, the SQLite assembly is restored on building. If Nuget version is older than 2.7, you need to select 'Restore NuGet Packages' from the solution's context menu.

  2. In Windows Explorer, open the following folder, and copy the ActiveTunes.SecurityProvider.dll assembly.
    C:\ActiveReports 12 Server\SDK\Samples\ActiveTunes.SecurityProvider\ActiveTunes.SecurityProvider\bin\Debug
  3. Paste the assembly into the following folder in your ActiveReports 12 Server installation folder.
    C:\ActiveReports 12 Server\SecurityProviders
  4. On the Administrator Dashboard, in the Configuration section, click Security Provider.
  5. From the Custom security provider drop-down that appears, select ActiveTunesSecurityProviderFactory.
  6. In the ConnectionString property that appears, enter the connection string:
     
    ConnectionString
    Copy Code
    Data Source=C:\ActiveReports 12 Server\SDK\Samples\ActiveTunes.SecurityProvider\ActiveTunes.sqlite
    
  7. To test the custom security provider, in the Login to test and Password to test boxes, enter test values from the table below.
    Login Password
    andrew@chinookcorp.com 1
    nancy@chinookcorp.com 2
    jane@chinookcorp.com 3
    margaret@chinookcorp.com 4
    steve@chinookcorp.com 5
    michael@chinookcorp.com 6
    robert@chinookcorp.com 7
    laura@chinookcorp.com 8
  8. Click the Test provider link to connect to the sample database and verify that the authentication is successful. You will see the following screen.

  9. Click the Apply changes button.
  10. Open the Report Portal and enter Login and Password values from the table above, e.g. nancy@chinookcorp.com and 2 as password.

  11. You are logged into the Report Portal as a user Nancy Edwards from the ActiveTunes security provider.

Now, when you edit the ActiveTunes sample model, you can apply either the EmployeeID or CustomerID filter to any entity.

To add row-level security to the ActiveTunes sample model

  1. On the Administrator Dashboard, in the Administration section, click Models.
  2. In the list of models that appears, next to the ActiveTunes (Sample) model, click the Edit command.
  3. In the model editor that appears, from the Entities list to the left, click the entity that you want to filter.
  4. In the workspace at the center, next to the Security Filter property, click the Add command.
  5. In the Edit Security Filter dialog that appears, in the box next to Filter Name, enter a name for your filter.
  6. Select Filter Expression, and click the ellipsis button next to the box under that label.
  7. In the Select Attribute dialog that appears, select the attribute to which you want to apply the filter condition, and click OK.
  8. To the right of the equals option, click the drop-down arrow and select UserContext.CustomerID or UserContext.EmployeeID.
  9. Click Apply to add the filter to the entity.
See Also