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
Aruna  
#1 Posted : Monday, November 16, 2015 10:09:06 AM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

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.
epf  
#2 Posted : Monday, November 16, 2015 11:12:46 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)
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;
        ...



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.