SQL Server 2005,权限验证
我正在用 C# 编写一个使用数据库 SQL Server 2005 的应用程序。它使用 Windows 身份验证。
问题是用户应该根据数据库中存储的信息获得权限。
Fe 我在数据库中存储有关不同项目的信息。每个项目都有一个领导者,每个项目属于某个领域,每个领域有管理员。 因此,启动某个项目的人应该只能修改该项目。 管理员也可以启动项目,但仍然无法修改其他项目。 这适用于不同的选择、更新和插入情况。
我不喜欢检查存储过程调用中的权限的想法,因为如果某些类别的工作人员的权限发生更改,则所有这些都应该被重写。
对于我的情况,控制访问的最佳方法是什么?
I'm writing an application in C# working with a database, SQL Server 2005. It uses Windows authentification.
The problem is that user should get rights according to information stored in database.
F.e. I store information about different projects in my database. Each project has a leader, each project belongs to a certain field, each field has administrator.
So the person, who started some project should be able to modify only that project.
Administrator also can start projects but still should be unable to modify other projects.
This applies to different select, update and insert cases.
I don't like the idea to check rights in a stored procedure calls, because all of them should be rewritten if the rights for some class of workers is changed.
What is the best way to control access in my case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法回避权限基于数据的事实,因此您需要在执行操作之前检查数据。也就是说,在代码中的某个地方。
这很简单,但这就是您的意思将不得不做。
对于存储过程,您可以调用另一个存储过程来检查权限,将所有检查集中在几个地方,以便于维护。
You can't get around the fact that permissions are based on data so you need to check data before an action. That is, in code somewhere.
This is simplified but it's what you'll have to do.
For stored procs, you can call another stored proc that will check rights to centralise all checks in just a few places for ease of maintenance.