IPrincipal 如何获得其角色?

发布于 2024-09-02 10:33:46 字数 275 浏览 0 评论 0原文

我需要了解 SiteMapProvider.IsAccessibleToUser() 的工作原理。

内置 XmlSiteMapProvider 调用 HttpContext.User.IsInRole(),在表单身份验证的情况下使用 System.Security.Principal.GenericPrincipal

当前用户从哪里获得其角色?哪个提供商加载此类信息?我想重载它并使用自定义逻辑。

I need to get know how SiteMapProvider.IsAccessibleToUser() works.

Built-in XmlSiteMapProvider calls HttpContext.User.IsInRole() which uses System.Security.Principal.GenericPrincipal in case of forms authentication.

Where does the current user gets its roles? Which provider loads this kind of information? I want to overload it and use custom logic.

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

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

发布评论

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

评论(2

空心↖ 2024-09-09 10:33:46

要使用自定义逻辑,您可以使用角色创建自己的表单身份验证 cookie,并在 Global.asax 中将其读回。

请参阅这些:

private void SetAuthenticationCookie(int employeeID, List<string> roles)

protected void Application_AuthenticateRequest(Object sender, EventArgs e)

http://weblogs.asp.net/rajbk/archive/2010/04/01/securing-an-asp-net-mvc-2-application.aspx

To use custom logic, you can create your own forms authentication cookie with roles and read it back in Global.asax.

See these:

private void SetAuthenticationCookie(int employeeID, List<string> roles)

protected void Application_AuthenticateRequest(Object sender, EventArgs e)

http://weblogs.asp.net/rajbk/archive/2010/04/01/securing-an-asp-net-mvc-2-application.aspx

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