具有 ActiveDirectory 身份验证的自定义角色提供程序
我正在基于 ASP.NET 角色提供程序创建自定义角色提供程序。我有3张桌子。一种用于用户,一种用于角色,一种用于 UsersInRoles。用户表没有密码列,因为用户是通过 ActiveDirectory 进行身份验证的。到目前为止,这就是我的方法。我无法让自定义角色提供者工作,任何人都有和我一样的情况。如何使自定义角色提供程序与 AD 配合使用?
I'm creating a custom Role provider based on the ASP.NET Role provider. I have 3 tables. One for Users, one for Roles, one for UsersInRoles.The Users table has no password column because the users are authenticated with ActiveDirectory. That's my approach so far. I can't get the cusstom Role Provider to work, anyone has the same situation like me. How do you make a custom Role provider works with AD?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我所做的:创建一个继承自 System.Web.Security.RoleProvider 的类,然后单击
: Roleprovider
时从上下文菜单中选择“实现抽象类”。我只实现了方法GetRolesForUser
(其他方法抛出NotImplementedException
)。在某个时刻,我认为我还需要实现 MembershipProvider,但是对 web.config 进行了简单的添加修复了它(由于程序集不在 GAC 中,因此在类型属性中,您只需要提及命名空间+类型-名称;不是程序集名称和其他参数):
无需在
MembershipProvider
上实现ValideUser
方法。What I did: create a class which inherits from
System.Web.Security.RoleProvider
, and choose "Implement abstract class" from the context menu when clicking on: Roleprovider
. I only implemented the methodGetRolesForUser
(the other methods throwNotImplementedException
).At a certain point I thought I also needed to implement the MembershipProvider, but a simple addition to web.config fixed it (since the assembly is not in the GAC, in the type-attribute, you only need to mention the namespace+type-name; not the assembly name and other parameters):
There is no need to implement the
ValideUser
method on aMembershipProvider
.您应该能够以重写 ValidateUser() 方法并强制其执行 AD 查找的方式编写角色提供程序。之后,大部分内置的东西应该接管。
You should be able to write the role provider in a manner to where you override the ValidateUser() method and force it to perform the AD lookup there. After that, most of the built in stuff should take over.