LINQ和數據庫權限 (LINQ and Database Permissions)


問題描述

LINQ 和數據庫權限 (LINQ and Database Permissions)

我仍在嘗試了解 LINQ 並訪問 SQL 數據庫。

我總是被教導,你應該只對你的數據擁有存儲過程的執行權限。

您永遠不應該選擇/插入/更新/刪除。

(這是因為性能和安全性)

要從 LINQ 中獲取數據,您顯然需要選擇權限。我知道你可以將存儲過程與 LINQ 一起使用,但既然我不能加入,那有什麼意義呢?

我錯過了什麼嗎???


參考解法

方法 1:

1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.

2) You can do joins with linq.

@Philippe: Linq automatically transforms evaluations into query parameters, so it provides some sql injection protection. However, you still have to closely evaluate your requirements to determine how much security you need and at what levels. Linq makes dealing with the database much easier, but it makes it easier to put secuirty design on the back burner, which is a bad thing.

方法 2:

I'm very much in agreement with Jeff Atwood on the "Stored Procedures vs. Inline SQL/LINQ" issue: Who Needs Stored Procedures, Anyways?.

I'm confused as to why you'd even want to perform a JOIN if you're in the SPROCs‑for‑everything crowd; shouldn't you wrap that JOIN up into another SPROC?

As Will said, LINQ wasn't designed for the kind of DB use you're talking about; it was designed to give us statically‑typed inline SQL. You could, however, still control access through user permissions if you use LINQ to SQL.

方法 3:

Well, for security reasons you should not input any user entered data into queries. If you stick with this rule, I don't see the problem of having select permission.

方法 4:

Whether all of your database access is "behind" stored procedures depends on the needs of the application and the company. I have implemented systems that use views to get all data and stored procedures for all updates. This allows for centralized security and database logic while still letting front‑end developers use SQL queries where appropriate.

Like so many other things in programming ‑ it depends on the needs for your project.

LinqToSql does support stored procedures. Scott Gu has a post on it:

http://weblogs.asp.net/scottgu/archive/2007/08/16/linq‑to‑sql‑part‑6‑retrieving‑data‑using‑stored‑procedures.aspx

(by Christian Payneuser1228Chris ZwirykPhilippePeter)

參考文件

  1. LINQ and Database Permissions (CC BY‑SA 2.5/3.0/4.0)

#permissions #linq-to-sql






相關問題

SharePoint/WSS:修改“創建者”字段? (SharePoint/WSS: Modify "created by" field?)

從 MS Access 訪問 .mdb 文件中的後端表 (Accessing backend tables in .mdb files from MS Access)

如何以編程方式對 AD OU 條目設置“列出內容”和“列出對象”權限? (How can I programmatically set "List Content" and "List Object" permissions on AD OU entries?)

嘗試使用 C# 設置註冊表權限時出現 NullReferenceException (NullReferenceException when trying to set registry permissions with C#)

可執行腳本在 Linux 機器上獲得權限被拒絕 (Executable script gets permission denied on Linux box)

iOS Facebook 令牌權限生日 (iOS Facebook token Permissions birthday)

如何使 644 個權限文件可從 PHP 寫入? (How do I make 644 permission files writable from PHP?)

Android 6.0 中的權限更改回調 (Permission changed callback in Android 6.0)

LINQ和數據庫權限 (LINQ and Database Permissions)

多個用戶可以訪問/更新 Market 中的單個 Android 應用程序嗎? (Can multiple users access/update a single Android app in the Market?)

運行具有權限的 Eclipse 應用程序或小程序 (Running Eclipse aplication or applet with permissions)

通過 AirWatch 卸載 Android APK (Uninstall Android APK via AirWatch)







留言討論