[英]SQL Server 2008 EF 4 - limiting database records returned using permissions?
In our database all tables are linked back to a single table. 在我们的数据库中,所有表都链接回到单个表。 This table has a bit column to limit whether the record is displayed.
该表有一个位列以限制是否显示记录。 Currently the records are filtered on the code side of the website.
当前,记录在网站的代码侧进行过滤。
Is there any way to set up permission so that userA would never see any record in the database where that common bit column was set to true? 有什么方法可以设置权限,以便userA永远不会在数据库中看到任何记录,而该公共位列设置为true?
We are using SQL Server 2008. 我们正在使用SQL Server 2008。
Alternatively we are also using entity framework 4.0 in .net 4 (in c#) if you have any ideas how it might be accomplished there? 或者,如果您有任何想法可以在其中实现它,我们也可以在.net 4(在C#中)中使用实体框架4.0。
Thanks for your feedback. 感谢您的反馈意见。
According to this excellent TechNet article , row level security is indeed possible with SQL server, if you structure your database accordingly, using views or stored procedures to limit the result by the current user. 根据这篇出色的TechNet文章 ,如果您相应地使用视图或存储过程来结构化数据库,以限制当前用户的结果,那么SQL Server确实可以实现行级安全性。 To my knowledge SQL Server does not have built in functionality for row level locking.
据我所知,SQL Server没有用于行级锁定的内置功能。
You could define a view on top of your table, which only shows those rows where that "active" column is set to 1 (true). 您可以在表顶部定义一个视图,该视图仅显示将“活动”列设置为1(true)的那些行。
You could then revoke the SELECT
permission on the underlying table from that group of users, but in turn grant them SELECT
on that new view you've created. 然后,您可以撤销
SELECT
从该组用户的基础表的权限,但反过来给予他们SELECT
的新观点,你已经创建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.