shalomd Posted December 2, 2009 Share Posted December 2, 2009 Hello,When I login to JasperServer with a certain user - how can pass the user role to the report so I can use this in the SQL.Is there a way to perform something similar in order to show a user only the data they are allowed to see?Example: if I login as Richard --> I can see only sales department, if I login as Tom --> I can see sales and production departments.ThanksShalom Link to comment Share on other sites More sharing options...
sjongenelen Posted December 2, 2009 Share Posted December 2, 2009 try domains :) Link to comment Share on other sites More sharing options...
shalomd Posted December 2, 2009 Author Share Posted December 2, 2009 first - thanks for the tip and quick answer :-)second - how can i use this in a query - ${LoggedInUser}.getRoles() , can u show me an example?thanks Link to comment Share on other sites More sharing options...
sjongenelen Posted December 2, 2009 Share Posted December 2, 2009 no this is not possible try to use roles on domains and reports... perhaps it can using SQL, but you're on the wrong forum for that - try mssql/mysql/oracle forums :) Link to comment Share on other sites More sharing options...
swood Posted December 10, 2009 Share Posted December 10, 2009 You can use roles and username in reports without domains, but you have some work to do. In a report define the follwing parameters: <!-- this is passed in automatically by JasperServer --> <parameter name="LoggedInUser" class="com.jaspersoft.jasperserver.api.metadata.user.domain.User"/><!-- these are dependent parameters --> <parameter name="LoggedInUserRoles" class="java.util.Collection"> <defaultValueExpression><![CDATA[$P{LoggedInUser}.getRoles()]]></defaultValueExpression> </parameter> <parameter name="LoggedInUserRolesAsStrings" class="java.util.Collection"> <defaultValueExpression><![CDATA[convert $P{LoggedInUserRoles} to collection of strings - Gtroovy or Java Expression, or scriptlet method call]]></defaultValueExpression> </parameter> <!-- use JasperReports $X to get the role name values into an IN clause --> <queryString> <![CDATA[select * from blahwhere $X{IN, role_name, LoggedInUserRolesAsStrings} ]]> </queryString>ShermanJaspersoft Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now