Rank: Member
Groups: Registered
Joined: 6/5/2020(UTC) Posts: 12 Thanks: 4 times
|
Hello, what is the name of a variable that can be inserted in SQL model and will be replaced with logged in user name ? Example of usage: Quote:exec sp_storedprocedure @username = {?} I also tried the following: https://sealreport.org/f...t.aspx?g=posts&t=157Quote: @{ ReportModel model = Model; string UserWeb = model.Report.SecurityContext.WebUserName; string result = "select '"+UserWeb+"'"; } @Raw(result)
But error " Object reference not set to an instance of an object." (I can not do security limitation in Additional WHERE Clause, it is way to rigid for my scenario) Regards, Tomaž Edited by user Friday, June 26, 2020 9:25:30 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Registered
Joined: 6/5/2020(UTC) Posts: 12 Thanks: 4 times
|
I finally figure it out. I found two options: 1) Pre SQL statement in Metadata model - executed before SQL modelQuote: @using Seal.Model @{ ReportModel model = Model; var userWeb = ""; if (model.Source.Report != null && model.Source.Report.SecurityContext != null){ var securityContext = model.Source.Report.SecurityContext; userWeb = securityContext.WebUserName; }
string result = "if object_id('tempdb..#tFilter', 'U') is not null "+ " drop table #tFilter "+ "create table #tFilter (name varchar(25), value nvarchar(1024)) "+ "insert into #tFilter(name, value) "+ "values('user_web', '"+userWeb+"') "
; } @Raw(result)
2) Pre SQL statement in data source repository - executed before every SQL queryQuote: @using Seal.Model @{ MetaSource source = Model; var userWeb = ""; if (source.Report != null && source.Report.SecurityContext != null){ var securityContext = source.Report.SecurityContext; userWeb = securityContext.WebUserName; }
string result = "if object_id('tempdb..#tFilter', 'U') is not null "+ " drop table #tFilter "+ "create table #tFilter (name varchar(25), value nvarchar(1024))"+ "insert into #tFilter(name, value) "+ "values('user_web', '"+userWeb+"') " ; } @Raw(result)
Edited by user Friday, June 26, 2020 4:41:20 PM(UTC)
| Reason: Not specified
|
|
|
|
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.