The record-level security (RLS) can be of report scope, which is based on the security information file. That is, you can use the security information file to set the security policies for a report. Report-scope security policy doesn't support column-level security (CLS).
Report-scope security has a higher priority than connection-scope security. That is, if in a report, both connection-scope and report-scope security have been applied, only the report-scope security will take effect.
The following example shows you how to set up a record-level security policy for a report:
<install_root>\Demo\Reports\SampleReports
, then open the sample report EmployeeInformation.cls.Since the record-level security policies are file-based, you can just create a new text file, add the security settings, and then link the file to your report. Below are steps detailing how to import the security information from a text file.
After you have set up RLS for reports in JReport Designer, you can then publish them to JReport Server as normal. Then, when you log onto JReport Server as different users, you will find that the record-level security settings have been applied to the report. Different users will only see the data that they are supposed to see.
Notes:
For example, both Customer ID >= 10 and Customer Name = 'Absolute Java' together will cause JReport Designer to retrieve records where customer ID is larger than or equal to 10 and the record with customer name equal to Absolute Java.
If you want to use logical AND for the relationship between each condition expression, use a formula that returns a Boolean value to filter the records. To specify the formula name for a report, in the Properties panel, select or type the formula name in the Function property entry.
For example, if user1 should only see records which satisfy the condition State = 'CO' and Customer ID >= 10, the formula should be:
if ( @State == 'CO' && @"Customer ID">= 10 ) return "user1"
If both the Record Level Security Information dialog and a formula have been used to control the security information, both will take effect. The relationship between them is logical OR.
User | Role | Column | Operator | Value | Title | |
---|---|---|---|---|---|---|
admin | admin | |||||
user1 | Customer ID | >= | 10 | user1@yoursite.com | Mr. | |
user1 | Customer Name | = | 'Absolute Java' | |||
user2 | Customer Name | IN | ('Absolute Java','American Coffee Inc.') | user2@yoursite.com | Miss | |
user3 | Phone | IN | ('(212) 555-3462','(317) 555-1274') | user3@yoursite.com | Mrs. |