如何针对未定义角色的数据存储编写 RoleProvider 代码?

发布于 2024-09-13 18:01:53 字数 369 浏览 10 评论 0原文

我正在考虑编写一个自定义 RoleProvider 来与外部第三方系统进行通信。但是,我需要的“角色”并未在系统中明确定义,而是基于系统内的条件。例如,角色可以定义为分配给特定委员会的人员或处于特定成员级别的人员。这意味着系统没有我想要使用的角色的概念,也没有定义它们的机制。显然,角色维护方法在这里毫无意义,并且将保持未实现状态,但角色查询方法必须在某处定义角色。

在这种情况下我该如何定义和使用角色?为这些信息维护一个单独的数据库将是一场噩梦。此外,该框架将用于角色完全不同的多个部署中。我一直认为我需要使用角色对象编写某种系统,其中包含确定用户是否处于该特定角色所需的逻辑,但我不知道如何使其与角色提供者模型一起使用。

我是否遗漏了一些明显的东西?我的想法完全错误吗?

I'm looking at writing a custom RoleProvider to talk to an external third-party system. However, the "roles" I need aren't explicitly defined in the system but are instead based on conditions within the system. For example, a role might be defined as someone who is assigned to a particular committee or someone who is at a particular level of membership. This means that the system has no concept of the roles I want to use and no mechanism for defining them. Clearly the role maintenance methods are meaningless here and would remain unimplemented, but the role query methods have to have the roles defined somewhere.

How can I define and use a roles in a situation like this? Maintaining a separate database for this information would be a nightmare. In addition, this framework would be used in multiple deployments where the roles would be completely different. I keep thinking that I need to code some sort of system with role objects that contain the logic required to determine if a user is in that particular role, but I can't figure out how to make it work with the Role Provider model.

Am I missing something blatantly obvious? Am I going about this completely wrong?

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

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

发布评论

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

评论(1

蓝眼泪 2024-09-20 18:01:53

好吧,你可以做一些事情;您可以创建一个角色提供者来占据他们在系统中的位置(委员会成员等)并将其转换为角色字符串。显然,您希望执行一次并缓存它们,但这是有可能的。

另一种选择是跳过内置的角色功能,在您的页面中只需检查它们的状态并据此验证它们;例如,他们是否有权查看该委员会,检查他们是否是成员,并允许他们;否则,拒绝他们。诸如此类的事情。

HTH。

Well, you could do a few things; you could create a role provider to take their position within your system (committee member, etc.) and translate that into a role string. Obviously, you'd want to do this once and cache them, but that is a possibility.

The other option is to skip the roles feature that's in built, and within your pages just check their status and validate them based upon that; for instance, do they have access to view this committee, check if they are a member, and allow them; otherwise, deny them. That sort of thing.

HTH.

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