请选择 进入手机版 | 继续访问电脑版

技术控

    今日:306| 主题:54156
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] SQL Server Reporting Services Column Level Security

[复制链接]
女圭女圭音せ 发表于 2016-9-30 12:14:30
170 5

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
By:Rahul Mehta |  |   Related Tips: > Reporting Services Security
   Problem

   In general, reports provide singular and comparative analysis and can be formatted as statistical, tabular or graphical. At times, confidential data should only be available to certain users. With SQL Server Reporting Services , how can we implement column level security in order to restrict a user's to view certain data.
  Solution

   SQL Server Reporting Services includes a feature called “Column Visibility” which can be used to implement column level security.  In this tip will we demonstrate column level security with the following steps:
  
       
  • First Step: Create a table to manage column level access to sensitive data on a per login basis.   
  • Second Step: Create a stored procedure to return the login column security information.   
  • Third Step: Build an SSRS report with a parameter in to read the login column security information from the stored procedure created in step 2.   
  • Fourth Step: Implement the “Column Visibility” feature to use the SSRS parameter to show or hide columns.  
   NOTE - This tip assumes you are proficient at building SQL Server Reporting Services Reports.  If you are new to the technology, check out this tutorial .
  Step 0 - Setup a Sample Data Set

  I have created a sample table called “Employee” with an identifier, name, age and salary.
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

  I have also created a sample report of the Employee table to show all columns from the table:
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   Step 1 - Sensitive Data Management

   Create a second table called "FieldRules" which has three fields: UserName(nvarchar), FieldName(nvarchar) and IsVisible(bit). Once created, add a sample record. In this case, I have added a sample user with field name (i.e. Salary) to show/hide the visibility (i.e. set to false) as shown below.
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   Step 2 - Stored Procedure to Return Data Access

   Create a stored procedure “ShowColumnInfo” to return the data access for the sensitive information for a specific UserID based on an input parameter:
  1. CREATE PROCEDURE [dbo].[ShowColumnnInfo] @UserID nvarchar(100)
  2. AS

  3. SELECT *
  4. FROM FieldRules
  5. WHERE UserName = @UserID
  6. GO
复制代码
Step 3 - Build the SQL Server Reporting Services Report

  To start building the report, create a DataSource (i.e. “DataSource1” in this example) in the SSRS report to access the database. Next, create a dataset called “ShowFieldDataSet” which will access the data from the FieldRules table using the dbo.ShowColumnInfo stored procedure as shown below.
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

  Also we have to create two parameters: UserID (to be passed as a parameter to stored procedure "ShowFieldDataset") which is shown above and FieldsToShow (which will pull “IsVisible” values from "ShowFieldDataSet") which is shown below.
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   Step 4 - Configure SQL Server Reporting Services Column Visibility

  The last step is to configure the “Salary” column to show/hide depending upon the value from the “FieldsToShow” parameter. Select the column in the SSRS report, right-click and select "Column Visibility". Configure the expression as shown in the figure below.
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

  Final SSRS Report Demonstration

   Now enter the login name (i.e. User ID), and it will show/hide the "Salary" column. In this case, we have configure the logic to not to show the "Salary" column for the user "Rahul" .
   

SQL Server Reporting Services Column Level Security

SQL Server Reporting Services Column Level Security

  Next Steps

  Last Update:



上一篇:Virtual dom it sucks
下一篇:Dynamically Generate SQL Server BCP Format Files
46561400 发表于 2016-9-30 23:38:48
我就路过,不说话。
回复 支持 反对

使用道具 举报

北京生活网b 发表于 2016-10-2 17:26:07
前排,哇咔咔
回复 支持 反对

使用道具 举报

蓝春 发表于 2016-10-5 01:42:33
鸟大了,什么林子都敢进啊!
回复 支持 反对

使用道具 举报

bangfu9hao 发表于 2016-10-7 14:50:59
别拿你的木马,挑战我的密码。
回复 支持 反对

使用道具 举报

huaxu956HG 发表于 2016-10-11 11:52:43
开往春天的坦克!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )

© 2001-2017 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表