Seal Report Forum
»
Report Edition
»
Advanced Tricks and Tips
»
How to access authenticated user details at Model level
Rank: Member
Groups: Registered
Joined: 11/4/2015(UTC) Posts: 17 Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
|
Hi,
I have web reports with basic authentication enabled in Seal report.
I need to filter the report data for logged in user. For this I need UserId at my report model. Could you please share sample razor script to get the authenticated user details at Model's "Pre Load Script" ?
Thanks In advance.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
Good question, actually I would recommend to use the table property 'Additional WHERE Clause' to filter directly the data in SQL. It will be more efficient. You have the sample script included: 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 also perform operation in the "Pre Load Script" and you can get access the security context object with: model.Report.SecurityContext this object is a SecurityUser with several public members: Code: public class SecurityUser
{
public string Name = "";
public List<SecurityGroup> SecurityGroups = new List<SecurityGroup>();
public SealSecurity Security;
public string Error = "";
public string Warning = "";
//Parameters to authenticate
public string WebUserName = "";
public string WebPassword = "";
public IPrincipal WebPrincipal = null;
public WindowsIdentity Identity = null;
...
|
|
|
|
Seal Report Forum
»
Report Edition
»
Advanced Tricks and Tips
»
How to access authenticated user details at Model level
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.