使用 ActiveDirectory 进行身份验证并使用自定义角色提供程序进行授权
我刚刚启动了一个小型 ASP.NET Web 应用程序。在这个项目中,我需要使用 Active Directory 对用户进行身份验证。我成功地使用 Active Directory 对用户进行了身份验证。但是对于自定义角色提供者的授权,我很困惑。你看,用户名和密码都存储在AD中。因此,我的方法是,在登录控件的 LoggedIn 事件之后,我检查 UserName 是否尚未存储在 Users 表中,然后我将 UserName 存储在那里。最后,我将 AD 用户的所有用户名存储在用户表中,以便我可以为用户分配角色。请参阅下面的表格图:
alt text http://img265.imageshack.us/img265 /5986/20100221200058.jpg
假设我将 UserA 分配给 RoleOne。他成功登录后,我做了一些查询来查找他的角色。
我在哪里保存角色票证?在Cookie中还是在Session中? ASP.NET角色提供者的授权是如何工作的?我也想像 ASP.NET 角色证明者那样存储授权票证。
I've just started a small ASP.NET web application. In this project, I need to authenticate the users with Active Directory. I managed to authenticate the users successfully with Active Directory. But with Authorization with Custom Role Provider, I'm so confused. You see, the user name and password are stored in AD. So, my approach is that after the LoggedIn event of the Login Control, I check if UserName is not yet stored in the Users table yet, then I will store the UserName there. Finally, I have all the UserName of the AD users store in the Users table so I can assign Roles to the users. Please see my tables diagram below:
alt text http://img265.imageshack.us/img265/5986/20100221200058.jpg
Let's say I assign UserA to RoleOne. After he logs in successfully, I do some query to look for his Roles.
Where do I keep the Role ticket? In the Cookie or in the session? How does the authorization of ASP.NET role provider work? I want to store the authorization ticket like ASP.NET role prover does too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过将 Active Directory 组用于角色和 WindowsTokenRoleProvider(或访问 AD 的自定义角色提供程序)?我发现这对于使用 AD 进行身份验证的情况非常有效。提示:使用 cookie 来存储用户的角色,这样您就不必在每次请求时都找到它们。
Have you considered using Active Directory groups for roles and the WindowsTokenRoleProvider (or a custom role provider accessing AD)? I find that this works very well for a situation where you're using AD for authentication as well. One tip: use cookies to store the user's roles so you don't have to find them on every request.