Jump to content

Selection of Where clause on the basis loggedinuse


ramandeep1980

Recommended Posts

Hi Everyone,

I will appreciate any help in process of authentication.Can we somehow dynamically select one out of 3  WHERE clause depending upon authentication  thru Loggedinusername and roles in use.

Depending upon the value in loggedinusername and role from Jiuser and jirole respectively. Can we select a where clause which is already written.I need this for row level security on reports.

I dnt want to put multiple WHERE clause in the query for report because it will slow down the reports.so i am looking to put these WHERE clause somewhere in the server or report from where they can be selected depending upon the user name and role they r in.

Regards,

Raman



Post Edited by ramandeep1980 at 10/11/2009 23:16
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi Sherman,

Thank you for replying.

Not exactly, thats not what im looking for.

What i am looking for is that i prepare 3 different types of WHERE clauses with diferent number of parameters in them

 

A.Where col_1= $P{x}

 

B.Where col_1= $P{x}

AND col_2 =$P{y}

 

C. Where col_1= $P{x}

AND col_2 =$P{y}

AND col_3 = $P{z}

 

 

Now on the bases of the Role user is in, I wanna select one of the above 3 values of WHERE- A,B or C

 

Andi dnt want to put these values in report query.So where can i put them and call them as per the requirement.

 

Regards,

Raman

 

 

Link to comment
Share on other sites

In your report JRXML, define the X, Y, Z parameters and input controls for them in JasperServer.

 

Then have a parameter with a default expression that generates the string you want to put in the where clause based on a test of the user's roles, like:

 

(In Groovy)

<parameter name="queryExpression" class="java.lang.String">

    <defaultExpression>

    if (${LoggedInUser}.roles.any{ it.roleName in ['ROLE_X'] }) {

         'col_1 = \'' + $P{X} + '\''

    } else if ( another test ) {

         'col_1 = \'' + $P{X} + \'' and col_2 = \'' + $P{Y} + '\''

    }

    </defaultExpression>

 </parameter>

...

<queryString>

...

where $P!{queryExpression}

</queryString>

 

If you want to do that in Java, have a complicated (test) ? string : ((test2) ? string :...)) or you could use a scriptlet.

 

 

Sherman

Jaspersoft

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...