具有不同类型角色的 ASP.NET 提供程序
在授权用户时,我需要考虑不同类型的角色。 例如:约翰必须拥有职位经理并且属于办公用品部门才能订购新计算机。
角色的问题是 Roles.GetRolesForUser("John") 只能返回字符串数组。
我应该使用自定义 roleProvider 和自定义 roleManager 吗? 或者我应该开发一个自定义 ProfileManager 来添加像 GetUsersWithProfileProperties() 这样的方法?
欢迎任何建议!
Thibaut
编辑:上面的例子被简化了,我可以有多达 4 种类型的角色,它们是 4 个不同的集合。
编辑:我发现一个非常相似的问题
I have different types of Roles to take into account when authorizing a user.
For example: John must have Position Manager and be part of the Office Supplies Department to order a new computer.
Problem with Roles is Roles.GetRolesForUser("John") can only return a string array.
Should I go with a custom roleProvider and custom roleManager?
or should I develop a custom ProfileManager to add methods like GetUsersWithProfileProperties()?
Any suggestion is welcome!
Thibaut
EDIT: the above example is simplified I could have a much as 4 types of roles which are 4 different collections.
EDIT: I found a very similar question
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从你写的内容来看;我相信您需要的一切目前都是开箱即用的:
请澄清我是否误解了您的问题。
From what you write; I believe that everything you need is currently available out of the box:
Please clarify if I have misunderstood your question.
为什么不创建一个具有路径到级别 typew 约定的“CompositeRoleProvider”来访问每个从属角色提供程序。您仍然需要创建多个角色提供程序,但您的复合或顶级提供程序会为您完成所有工作。
我计划用 ProfileProvider 做类似的事情
why not create a "CompositeRoleProvider" with a Path-To-Level typew convention for accessing each subordinate role provider. You will still have to create multiple role providers, but your Composite or Top-Level Provider does all of the work for you.
I plan to do a similar thing with ProfileProvider
我正在研究如何解决一个非常相似的问题,我得出的结论是,最好的办法是实现自定义角色提供程序。
我使用这个(http://msdn.microsoft.com/en-us/library/317sza4k(v=vs.100).aspx)作为基础,我将实现我的方法,例如(IsManager,GetDepartment,ecc) 。
数据将存储在连接到 aspnet_users 表的自定义表中。
希望它可以帮助将来的人:)
I'm studying how to solve a pretty similar problem and I've come to a conclusion that the best thing to do is to implement a custom role provider.
I'm using this (http://msdn.microsoft.com/en-us/library/317sza4k(v=vs.100).aspx) as a base and I will implement my methods like (IsManager, GetDepartment, ecc).
Data will be stored in custom tables that are joined to the aspnet_users table.
Hope it may help someone in the future :)
我认为有一个方法 GetUsersInRole。
http://msdn.microsoft.com/ en-us/library/system.web.security.roles.getusersinrole.aspx
I think there is a method GetUsersInRole.
http://msdn.microsoft.com/en-us/library/system.web.security.roles.getusersinrole.aspx