How to Display the Username of the User Logged into JasperServer
Many times we need to know the name of the person who logged into JasperServer. Based on this information, we can show or hide elements in a report or simply log the username.
Steps to Achieve This
- Create parameters in your report with specific names and data types. These parameters will be automatically filled when the report runs on JasperReports Server.
- For example, create a parameter:
- Name:
LoggedInUsername - Type:
java.lang.String - Default Value: None
- Name:
- You can then use
$P{LoggedInUsername}in a text field, query, or printWhenExpression. - Note: If you run the report in iReport, this value will be null. Deploy the report on JasperServer for correct results.
Available JasperServer Built-in Parameters
| Parameter Name | Type | Notes |
|---|---|---|
| LoggedInUser | User | Not usable in query input control, but is used as a parameter in the report |
| LoggedInUsername | String | Username of the logged-in user |
| LoggedInUserFullName | String | Full name of the logged-in user |
| LoggedInUserEmailAddress | String | Email of the logged-in user |
| LoggedInUserEnabled | Boolean | Is the logged-in user enabled? |
| LoggedInUserExternallyDefined | Boolean | Is the user externally defined (authenticated externally)? |
| LoggedInUserTenantId | String | Relevant only in Pro/Enterprise editions |
| LoggedInUserRoles | Collection<String> | Current set of roles of the logged-in user |
| LoggedInUserAttributes | Map<String, String> | Not usable in query input control. Empty map if no attributes |
| LoggedInUserAttributeNames | Collection<String> | User profile attribute names. Empty if no attributes |
| LoggedInUserAttributeValues | Collection | - |
| LoggedInUserAttribute_<attribute name> | String | Value of a specific user attribute, empty if not defined |
Using these parameters, you can easily get various user details which are helpful for definin
Post a Comment