logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
vins  
#1 Posted : Wednesday, May 25, 2016 10:31:10 AM(UTC)
vins

Rank: Newbie

Groups: Registered
Joined: 5/25/2016(UTC)
Posts: 2
Italy
Location: Roma

Thanks: 1 times
Hi everyone,
I'm new with Seal Report.

Is possible to use the user (SecurityUser object defined in the authentication) as a restriction for a report (also via the Report Designer) ?

For example, I have a list of Site ID need to be passed as filter to the report, but the Site ID should be filtered by User Id.

Hope is clear.. and thank you for your help.




epf  
#2 Posted : Wednesday, May 25, 2016 3:21:48 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 552
Switzerland

Thanks: 7 times
Was thanked: 78 time(s) in 76 post(s)
Yes, you can use the SecurityContext object, but only when connected with the Web Report Server as there is no security with the Report Designer.
A classic approach is to define a dynamic "Additional Where Clause" in your table defined in your source.
Then use Razor Script to do what you want, here is the template to filter on the logged user name:

Code:
@using Seal.Model
@using Seal.Helpers
@{
  MetaTable table = Model;
  string restriction = Environment.UserName;
  if (table.Source.Report != null && table.Source.Report.SecurityContext != null)
  {
    restriction = table.Source.Report.SecurityContext.Name;
  }
  string result = string.Format("aColumnName={0}", Helper.QuoteSingle(restriction));
}
@Raw(result)



You can read also this post on security:
http://forum.sealreport.org/default.aspx?g=posts&t=89#post171
thanks 1 user thanked epf for this useful post.
vins on 5/25/2016(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.