Seal Report Forum
»
Report Edition
»
Reports
»
Backend filter by authenticated user
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
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 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
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/6/2015(UTC) Posts: 2
|
That helped :) Thank you very much!
|
|
|
|
Seal Report Forum
»
Report Edition
»
Reports
»
Backend filter by authenticated user
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.