Fine-Grained Permission Control by Parameter

  • Last update:June 30, 2023
  • Overview

    Version

    Report Server Version

    11.0

    Functions

    After user identity authentication, three fixed default parameters $fine_username, $fine_role, and $fine_position will be saved in Session.

    Two functions GETUSERDEPARTMENTS() and GETUSERJOBTITLES() are provided to respectively obtain the departments and positions of roles.

    In the same report environment, the corresponding values can be directly obtained in the template as parameters, and then different data and styles can be displayed by filtering and judging in the template.

    Parameters Introduction

    Note:

    1. $fine_username, $fine_role and $fine_position are default parameters in FineReport, so their cases must be consistent when you call them.

    2. Analog calculation is not supported.                                              

    Parameter

    Description

    Example

    $fine_username

    Gets the login username of the system.

    For example, the login username is Anna.

    $fine_username=Anna

    $fine_display_name

    Gets the login name (username) of the system.

    For example, the login name is Xia Mei (Anna).

    $fine_display_name=Xia Mei (Anna)

    $fine_role

    Gets the login role of the system.

    1. The user is a super admin.

    $fine_role=superusers

    2. The role of the user is Data Architect.

    $fine_role=Data Architect

    3. The user has no role.

    The parameter value is empty.

    4. There are multiple roles for the user, such as Sales director and Development engineer.

    $fine_role=Sales director,Development engineer

    $fine_position

    Gets positions and departments. Returnan array consisting of departments and positions.

    1. The user is Human resources-Director.

    $fine_position={"departments": "Human resources", "jobTitle": "Director"}2. The user is both Human resources-Director and Leadership department-President.

    $fine_position={"departments": "Human resources", "jobTitle": "Director"}, {"departments": "Leadership department", "jobTitle": "President"}

    3. The user has no position in a department, and the parameter value is empty.

    GETUSERDEPARTMENTS()

    Gets the departments from departments and positions.

    If there are multiple levels in the department, it will return all levels; if there are multiple departments, it will return all departments.

    1. The user is Human resources-Director.

    GETUSERDEPARTMENTS()=Human resources

    2. The user is Sales department-Eastern Sales Department-Leader.

    GETUSERDEPARTMENTS()=Sales department, Eastern Sales Department

    3. The user is both Human resources-Director and Leadership department-President.

    GETUSERDEPARTMENTS()=Human resources, Leadership department

    4. The user belongs to no department, and the parameter value is empty.

    GETUSERDEPARTMENTS(X)

    Gets the target level department from the departments and positions.

    If the target level department does not exist, it will return null.

    1. The user is Sales department-Eastern Sales Department-Eastern Sales Group 1-Leader.

    GETUSERDEPARTMENTS(3)=Eastern Sales Group 1

    GETUSERDEPARTMENTS(3,2)=Eastern Sales Group 1, Eastern Sales Department

    2. The user is Sales department-Eastern Sales Department-Leader

    GETUSERDEPARTMENTS(3) is empty

    GETUSERDEPARTMENTS(3,2)=Eastern Sales Department

    GETUSERJOBTITLES()

    Gets the positions of the departments and positions.

    If there are multiple positions, it will return all positions.

    1. The user is Human resources-Director.

    GETUSERJOBTITLES()=Director

    2. The user is both Human resources-Director and Leadership department-President.

    GETUSERJOBTITLES()=Director, President

    3. The user has no position, and the parameter value is empty.

    Example One: Displaying Data Based on Login Username

    Anna is one of the users in the decision-making platform.

    In the database Sales_Basic, there is a data column Salesperson, which corresponds to the username in the decision-making platform.

    Create a template Display Content Based on Login Username based on Sales_Basic and mount it to the directory of the platform.

    Anna logs in to the system and can view the template displaying her own sales data, but cannot see the content of others.

    Note: Take dataset parameters as an example in this chapter. Template dataset is also workable.

    Creating a Template

    Open the designer and create a general report.

    Create a database query ds1: SELECT * FROM Sales WHERE Salesperson='${fine_username}'

    Get the username for logging into the system. For example, if the login username is Alice, then $fine_username=Alice.

    Designing a Template

    Mounting the Template to the Platform

    The Admin logs into the decision-making platform, clicks Manage > Directory, selects Manage Directory, and clicks Add Template.

    Select the template created in section "Displaying Data Based on Login Username", and click Next. Select Preview for Type, tick PC for Terminals, and click OK.

    Configuring the Viewing Permission for the Template

    The Admin logs in to the decision-making platform and clicks Manage > Permission > General permission configuration.

    Select the permission carrier as All Departments and assign the View permission for the directory Display Data Based on Login Username.

    Demonstration

    User Anna (Anna, 123456) logs into the decision-making platform, views the template, and she can only see her own sales data.

    Downloading the Template

    Click to download the template: Display Data Based on Login Username.cpt

    Note: Make sure that there is platform user Anna the same as that of the Salesperson in the template. Otherwise the final effect cannot be displayed.

    Example Two: Displaying Rows and Columns Based on Login Roles

    When different roles open the template, they will see different numbers of columns and different colors of rows and columns. You can add conditions to rows and columns such as setting row height, column width and background.

    In decision-making platform, Anna belongs to the role of Sales director, while user Alice does not.

    The template is mounted in the directory with a column Sales Volume.

    When user Alice logs into the decision-making platform to view the template, she can see the column Sales Volume.

    However, when user Anna logs into the decision-making platform to view the template, she cannot see the column Sales Volume.

    Creating a Template

    Open the designer and create a general report.

    Create a database query ds1: SELECT * FROM Sales_Basic

    Designing a Template

    Setting Conditional Formatting

    Select cell E2, click Add Condition under Conditional Formatting on the right.

    Set Column Width in Attributes to 0 millimeters and Common Condition as Formula, enter $fine_role='Sales director', and click Add.

    Note: If a user has multiple roles, the formula is find('Sales director', $fine_role)>0.

    Mounting the Template to the Platform

    The Admin logs into the decision-making platform, clicks Manage > Directory, selects Manage Directory, and clicks Add Template.

    Select the template created in section "Displaying Rows and Columns Based on Login Roles", and click Next. Select Preview for Type, tick PC for Terminals, and click OK.

    Configuring the Viewing Permission for the Template

    The Admin Logs in to the decision-making platform and clicks Manage > Permission > General permission configuration.

    Select the permission carrier as All departments and assign the View permission for the directory Display Rows and Columns According to Different Roles.

    Demonstration

    When user Xia Mei (Alice, 123456) logs in to the decision-making platform to view the template, she can see the column Sales Volume.

    When the user Anna (Anna, 123456) logs into the decision-making platform to view the template, she cannot see the column Sales Volume.

    Downloading the Template

    Click to download the template: Display Rows and Columns According to Different Roles.cpt


    Attachment List


    Theme: Decision-making Platform
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy