基于用户的不同 asp:menu
我有一个 Oracle 数据库,用于存储本地 Intranet 的菜单和用户数据。
该数据包括哪些用户有权访问哪些页面。
最初,我创建了一个扩展 StaticSiteMapProvider 类的类,但是当它进入测试环境时,我发现它是为整个站点缓存的(而不是基于用户)。在各种论坛上在线阅读后,建议我应该从 SiteMapProvider 继承,因为这将使我能够在用户基础上拥有 SiteMapProvider 和 ASP:MENU 项目的单独实例,但这仍然没有解决问题。
目前我有一个用户控件,它限制 asp:menu,并使用我的自定义站点地图提供程序作为其数据源。
谁能建议我如何在数据库授权的驱动下以用户为基础显示菜单?
此外,整个菜单仍然应该向所有用户显示,只有在单击菜单节点后,他们才会发现他们是否有权访问该页面/节点。
谢谢
I have a oracle database which stores menu and user data, for a local Intranet.
The data includes which usesr have access to which pages.
Originally I created a class which extened the StaticSiteMapProvider class, however when this went in to the testing environment, i found that this was cached for the whole site (and not on a user basis). After reading up on line on various forums, it was suggested that I should inherit from SiteMapProvider as this would enable me to have a seperated instance of thet SiteMapProvider and ASP:MENU item on a user basis, however this still hasn't solved the problem.
Currently I have a user control, which conrains the asp:menu, and uses my custom site map provider as its data source.
Could anyone suggest how I can display the menu on a user basis, driven from database authorisation?
Also the whole menu should still appear to all users, it only after thy click on a menu node that they will find out whether they have access to that page/node.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用站点地图上的角色来定义将显示的菜单。
You can make use of Roles on the SiteMap to define what menu will appear.
这里有两件事。如果您有静态节点集合,然后想要根据用户可访问性显示/隐藏它们,那么您应该覆盖 IsAccessibleToUser
方法来判断给定节点是否适用于当前用户(可从给定的 HttpContext 访问)。
如果您的节点集合/层次结构根据每个用户进行更改,请尝试覆盖 BuildSiteMap 为当前用户加载不同的节点。但是,我有点怀疑 StaticSiteMapProvider 在这种情况下是否是正确的基类。可能您需要从
SiteMapProvider
进行覆盖。There are two things here. If you have static collection of nodes and then you want to show/hide them based on user accessibility then you should override IsAccessibleToUser
method to tell if the given node if applicable for the current user (accessible from given HttpContext).
In case, your nodes collection/hierarchy changes per user basis then try overriding BuildSiteMap to load different nodes for current user. However, I am a bit doubtful if StaticSiteMapProvider is the correct base class in this case. Probably you need to override from
SiteMapProvider
.