Get user who executes report

Hi,

Is there a way to pass to a Jasper report the details of the ReportServer user executing the report?

I searched the docs and the forum and found nothing on this.

Regards,
Sabina

Hi Sabina,

you can access your user in Jasper by creating a parameter (only in Jasper!) like this:

<parameter name="_RS_USER_FIRSTNAME" class="java.lang.Object"/>

You can use of course String for text.

Then you can print it in your jasper like any other parameter:

<textField>
   <reportElement x="138" y="70" width="138" height="60" uuid="88a0b516-0d6a-48b8-8ae8-b479b35a948b"/>
   <textFieldExpression><![CDATA[$P{_RS_USER_FIRSTNAME}]]></textFieldExpression>
</textField>

The user fields that are accessible are:

  • _RS_USER_FIRSTNAME
  • _RS_USER_LASTNAME
  • _RS_USER_USERNAME
  • _RS_USER_TITLE
  • _RS_USER_EMAIL
  • _RS_USER_ID

Regards,
Eduardo

Thank you, it was very helpful.