SQL Server 2008 EF 4 - 使用权限限制返回的数据库记录?
在我们的数据库中,所有表都链接回单个表。该表有一个位列来限制记录是否显示。目前,记录是在网站的代码端进行过滤的。
有没有什么方法可以设置权限,以便 userA 永远不会看到数据库中公共位列设置为 true 的任何记录?
我们正在使用 SQL Server 2008。
或者,我们也在 .net 4(c# 中)中使用实体框架 4.0,如果您有任何想法如何在那里完成它?
感谢您的反馈。
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?
We are using 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?
Thanks for your feedback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在表顶部定义一个视图,该视图仅显示“活动”列设置为 1 (true) 的行。
然后,您可以撤销该用户组对基础表的
SELECT
权限,但反过来授予他们对您创建的新视图的SELECT
权限。You could define a view on top of your table, which only shows those rows where that "active" column is set to 1 (true).
You could then revoke the
SELECT
permission on the underlying table from that group of users, but in turn grant themSELECT
on that new view you've created.根据 这篇优秀的 TechNet 文章,使用 SQL 确实可以实现行级安全性服务器,如果您相应地构建数据库,请使用视图或存储过程来限制当前用户的结果。据我所知,SQL Server 没有内置的行级锁定功能。
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. To my knowledge SQL Server does not have built in functionality for row level locking.