SQL 登录访问 ASP.Net 应用程序数据库的权限

发布于 2024-07-15 12:05:35 字数 153 浏览 6 评论 0原文

我总是想知道我需要为 sql 登录提供哪些确切的访问权限和权限,我从 ASP.NET 应用程序中使用该登录来访问数据库。 应用程序执行一些存储过程,将数据插入、更新和删除到表中。 我也直接在表格上选择、删除、更新。 此外还有一些触发器。 想知道是否有权限矩阵的完整列表可以提供帮助。

I always wonder what are the exact access rights and permissions I need to give to a sql login which I use from my asp.net application to access database. The application execute some stored procedures which insert, update and delete data into tables. I do select, delete, update directly on the tables also. Also there are some triggers.
Wonder if there is a comprehensive list of the permission matrix to help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

话少心凉 2024-07-22 12:05:35

好吧,这取决于您想要使其复杂程度:-)

最简单的解决方案:

  • 让您的登录/数据库用户具有 db_datareader 角色来读取所有表
  • 让您的登录/数据库用户具有 db_datawriter 角色来读取 所有表写入所有表

至于执行存储过程,我们所做的是在数据库中创建一个新的自定义数据库角色“db_executor”,如下所示:

CREATE ROLE [db_executor] AUTHORIZATION [dbo]
GRANT EXECUTE TO [db_executor]

然后我们也将该角色授予 db 用户。 这个新的自定义数据库角色将对数据库中所有现有的所有未来存储的过程/函数拥有执行权限。

这样,您的数据库用户就可以读取和写入任何表并执行任何存储过程和存储函数。

更复杂的解决方案:
当然,您也可以将单个表、视图、过程、函数的权限授予单个数据库用户和/或数据库角色。 但它可能会变得非常混乱和复杂。

马克

Well, it depends on how complicated you want to make it :-)

Simplest solution:

  • make your login / db user have the db_datareader role to read all tables
  • make your login / db user have the db_datawriter role to write all tables

As for executing stored procs, what we did is create a new custom database role "db_executor" in our database like this:

CREATE ROLE [db_executor] AUTHORIZATION [dbo]
GRANT EXECUTE TO [db_executor]

and then we grant this role to the db user as well. This new custom database role will have execute rights on all existing AND on all future stored procs/funcs in your database.

With this, your db user can read and write any table and execute any stored proc and stored func.

More complex solution:
You can of course also GRANT permissions on individual tables, views, procs, funcs to inidividual db users and/or db roles. But it can get quite messy and complicated.

Marc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文