logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


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

Notification

Icon
Error

Options
Go to last post Go to first unread
aryadna22  
#1 Posted : Wednesday, May 6, 2015 8:59:48 AM(UTC)
aryadna22

Rank: Newbie

Groups: Registered
Joined: 5/6/2015(UTC)
Posts: 2

Dear Support,

I'm on an analyzing phase regarding Seal Report. It seems a great product for what I need, but I have a concern.
After configuring Database Authentication, it is possible to limit the logged-in user to data that has access to (for example, I have users associated with territories, so each user should only see the data filtered by his territories). Is this simple to achieve?
Thank you!

Ary
epf  
#2 Posted : Wednesday, May 6, 2015 11:09:32 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Yes, it is possible to filter the data returned depending on the context (typically user connected)

This is achieved with the table property: 'Additional WHERE Clause'.
If the table is involved in the query to build up a model, the 'Additional WHERE Clause' will be added in the WHERE clause of the SQL.

In your Data Source, select the table you want to filter, then edit the 'Additional WHERE Clause' where you can either user direct SQL
like
Code:
aColumnName = CURRENT_USER

for getting the user connected in SQLServer...if you have authenticated your user with the Database

or even more powerful you can use a C# Script like

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)


Where Environment.UserName is the windows user name,
and Report.SecurityContext.Name is a user name connected through the Web Report Server (= Windows user name for the integrated windows authentication mode in IIS).

Note that this sample is based on the coming 1.7 version (SecurityContext is not a member of Report in 1.6) that should come this week...

Edited by user Wednesday, May 6, 2015 11:10:38 AM(UTC)  | Reason: Not specified

aryadna22  
#3 Posted : Wednesday, May 6, 2015 12:05:35 PM(UTC)
aryadna22

Rank: Newbie

Groups: Registered
Joined: 5/6/2015(UTC)
Posts: 2

That helped :) Thank you very much!
Users browsing this topic
Guest
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.