如何针对未定义角色的数据存储编写 RoleProvider 代码?
我正在考虑编写一个自定义 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你可以做一些事情;您可以创建一个角色提供者来占据他们在系统中的位置(委员会成员等)并将其转换为角色字符串。显然,您希望执行一次并缓存它们,但这是有可能的。
另一种选择是跳过内置的角色功能,在您的页面中只需检查它们的状态并据此验证它们;例如,他们是否有权查看该委员会,检查他们是否是成员,并允许他们;否则,拒绝他们。诸如此类的事情。
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.