使用角色进行 CRUD 限制的 Windows 身份验证

发布于 2024-12-06 21:48:30 字数 281 浏览 0 评论 0原文

我是一名学生,正在开发一个与 SharePoint 有一些共同点的网站。我使用 ASP.NET MVC 3 创建一个 Intranet 站点,以便人们可以通过 Active Directory 进行身份验证。我在实现这些要求时遇到了困难:

  1. 用户可以定义角色(不是 AD 组)并将 Active Directory 用户链接到这些角色。
  2. 上传文档或文件夹时,用户可以向角色授予对文档的 CRUD 访问权限,也可以限制角色对文档的访问权限。

请帮助我或给我一个好文章的链接:)

I am a student who is working on a website that has some things in common with SharePoint. I use ASP.NET MVC 3 to create an intranet site so people can be authenticated by Active Directory. I have trouble implementing these requirements:

  1. Users can define roles (not AD groups) and link Active Directory users to these roles.
  2. When documents or folders are uploaded, the user can give roles CRUD access to the document or can restrict roles from it.

Please help me or give me a link to a good article:)

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

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

发布评论

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

评论(1

厌倦 2024-12-13 21:48:30
CREATE TABLE role
(
  role NVARCHAR(50) NOT NULL PRIMARY KEY,
  create BIT NOT NULL,
  read   BIT NOT NULL,
  update BIT NOT NULL,
  delete BIT NOT NULL
)

CREATE TABLE item
(
  id INT NOT NULL PRIMARY KEY,
  name NVARCHAR(50) NOT NULL,
  id_parent INT,
  CONSTRAINT FK_item_item FOREIGN KEY(id_parent) REFERENCES item(id)
)

CREATE TABLE user
(
  id INT NOT NULL PRIMARY KEY,
  adUserName NVARCHAR(50) NOT NULL,
  role NVARCHAR(50) NOT NULL,
  CONSTRAINT FK_user_role FOREIGN KEY(role) REFERENCES role(role)
)

CREATE TABLE user_item_rights
(
  id_user INT NOT NULL,
  id_item INT NOT NULL,
  create BIT NOT NULL,
  read   BIT NOT NULL,
  update BIT NOT NULL,
  delete BIT NOT NULL,
  CONSTRAINT PK_user_item_rights PRIMARY KEY(id_user,id_item),
  CONSTRAINT FK_user_item_rights_user FOREIGN KEY(id_user) REFERENCES user(id),
  CONSTRAINT FK_user_item_rights_item FOREIGN KEY(id_item) REFERENCES item(id)
)

这应该会让您了解如何实现这一点。您也可以将其翻译为类。您还可以实现 CRUD 继承等,或者定义一个 role_item_right 表。
在我看来, user_item_rights 会覆盖角色中的默认设置。

CREATE TABLE role
(
  role NVARCHAR(50) NOT NULL PRIMARY KEY,
  create BIT NOT NULL,
  read   BIT NOT NULL,
  update BIT NOT NULL,
  delete BIT NOT NULL
)

CREATE TABLE item
(
  id INT NOT NULL PRIMARY KEY,
  name NVARCHAR(50) NOT NULL,
  id_parent INT,
  CONSTRAINT FK_item_item FOREIGN KEY(id_parent) REFERENCES item(id)
)

CREATE TABLE user
(
  id INT NOT NULL PRIMARY KEY,
  adUserName NVARCHAR(50) NOT NULL,
  role NVARCHAR(50) NOT NULL,
  CONSTRAINT FK_user_role FOREIGN KEY(role) REFERENCES role(role)
)

CREATE TABLE user_item_rights
(
  id_user INT NOT NULL,
  id_item INT NOT NULL,
  create BIT NOT NULL,
  read   BIT NOT NULL,
  update BIT NOT NULL,
  delete BIT NOT NULL,
  CONSTRAINT PK_user_item_rights PRIMARY KEY(id_user,id_item),
  CONSTRAINT FK_user_item_rights_user FOREIGN KEY(id_user) REFERENCES user(id),
  CONSTRAINT FK_user_item_rights_item FOREIGN KEY(id_item) REFERENCES item(id)
)

This should give you a idea of how you could implements this. You could also translate it to classes. You could also implement CRUD inheritance and so, or define a role_item_right table.
In my idea the user_item_rights overrides the default settings in the role.

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