角色提供者和角色管理

发布于 2024-09-01 06:25:36 字数 850 浏览 7 评论 0原文

当 Web.config 文件中的 CacheRolesInCookie 属性设置为 true 时,每个用户的角色信息将存储在 cookie 中。当角色管理检查用户是否处于特定角色时,会在调用角色提供程序以检查数据源中的角色列表之前检查角色 cookie。 Cookie 会动态更新以缓存最近验证的角色名称。

a) 据我理解上面的文字,即使角色管理检查角色cookie,角色提供者仍然检查数据源的角色列表?

b) 上面的文字讨论了角色管理,它在调用角色提供者之前调用。什么类充当角色管理?

谢谢

编辑:

据我了解,cookie 中缓存的信息包括所有可用的角色,而不仅仅是您的用户所属的角色。所以我不相信数据库每次都会被命中。

来自与我上一篇文章的引用相同的网站:

Roles.CacheRolesInCookie 属性值

如果当前用户的角色缓存在 cookie 中,则为 true;否则为假。默认为 true。

这表明只有当前用户的角色存储在 cookie 中。此外,如果所有角色都存储在 cookie 中,那么角色管理器仍然需要检查数据库以查看当前用户属于哪个角色?!

角色管理由 System.Web.Security.Roles 类处理。

我认为本文使用术语“角色管理”来指代调用 System.Web.Security.Roles 方法的类/模块,这反过来又检查用户是否是特定角色的成员?

When the CacheRolesInCookie property is set to true in the Web.config file, role information for each user is stored in a cookie. When role management checks to see whether a user is in a particular role, the roles cookie is checked before the role provider is called to check the list of roles at the data source. The cookie is dynamically updated to cache the most recently validated role names.

a) As far as I understand the above text, even though role management checks the roles cookie, role provider still checks the list of roles at the data source?

b) Above text talks about role management, which is invoked before role provider is called. What class acts as a role management?

thanx

EDIT:

As far as I understand it, the information cached within the cookie includes all available roles, not just the ones your user is a member of. So I do not believe that the database would be hit each and every time.

From same site as the quote from my previous post:

Roles.CacheRolesInCookie Property Value

true if the current user's roles are cached in a cookie; otherwise, false. The default is true.

This suggests that only roles for current user are stored in a cookie. Besides, if all roles where stored in a cookie, then role manager would still have to check the DB to see which of the roles current user is member of?!

Role management is handled by the System.Web.Security.Roles class.

I thought the text used the term role management to refer to class/module that calls the methods of System.Web.Security.Roles, which in turn check whether user is a member of particular role?

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

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

发布评论

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

评论(1

佞臣 2024-09-08 06:25:36

角色管理由 System.Web.Security.Roles 类处理。据我了解,cookie 中缓存的信息包括所有可用的角色,而不仅仅是您的用户所属的角色。所以我不相信数据库每次都会被击中。

如果您要更改可用角色列表(即通过创建新角色),则提供程序将在下一个往返时使 cookie 中的缓存失效。

//理查德.

Role management is handled by the System.Web.Security.Roles class. As far as I understand it, the information cached within the cookie includes all available roles, not just the ones your user is a member of. So I do not believe that the database would be hit each and every time.

If you were to change the list of available roles (i.e. by creating a new role), then the provider would invalidate the cache in the cookie on the next round trip.

//Richard.

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