简体   繁体   English

SQL Server 2008 EF 4-限制使用权限返回的数据库记录?

[英]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.

相关问题 如何授予SQL Server 2008数据库从C#Windows应用程序中的客户端系统插入数据的权限? - How to give the permissions to sql server 2008 database to insert the data from client system in c# windows application? 使用 LINQ 将数据库从 SQL Server 2008 R2 更改为 SQL Server 2008 - Using LINQ changing database from SQL Server 2008 R2 to SQL Server 2008 一个模型还是两个模型? -SQL Server(2005/2008)的数据库优先EF 6.0需要对SQL Server CE 4.0的脱机支持 - One Model or Two? - Database First EF 6.0 to SQL Server (2005/2008) needs offline support to SQL Server CE 4.0 使用C#连接到SQL Server 2008 Express数据库 - Connect to SQL Server 2008 Express database using C# 使用C#连接到SQL Server 2008数据库 - Connecting to sql server 2008 database using C# 使用SQL Server 2008或任何dbms的数据库应用程序 - Database application using SQL Server 2008 or any dbms 无法使用C#编辑SQL Server 2008数据库中的表 - Unable to edit tables in SQL Server 2008 database using C# 使用C#从SQL Server 2008数据库检索图像 - retrieving image from sql server 2008 database using c# 首先使用ef核心代码将密码存储在sql服务器数据库中 - storing passwords in sql server database using ef core code first 奇怪的问题:在使用SQL Server 2008 R2的Razor在ASP.NET MVC 3中创建记录时,数据库更新率为60-40 - Weird problem: 60-40 database update rate while creating records in ASP.NET MVC 3 with Razor using SQL Server 2008 R2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM