您可以将自定义会员资格提供程序与 userNamePasswordValidationMode 结合使用吗?
我看到的每个示例都使用带有 userNamePasswordValidationMode 的默认成员资格提供程序,但是如果我有自定义成员资格提供程序,我可以在 WCF REST 服务的 ServiceCredentials 中为 userNamePasswordValidationMode 指定 MembershipProvider 吗?如果可能的话,最好采用以下路线:
创建一个实现成员资格提供程序的自定义成员资格提供程序。
创建一个实现 UserNamePasswordValidator 的 CustomUserNamePasswordValidator 并重写验证方法。
在 Validate 方法中,验证数据库中是否存在用户。
我遇到的问题是,如果我的服务中有一个登录方法,并且是从具有 url http://test.com/service.svc/login,如何获取用户名和密码。假设用户名和密码可以输入到网页中,也可以来自智能设备应用程序(android、iphone 等)
Every example I see uses the default Membership Provider with the userNamePasswordValidationMode, but can I specify MembershipProvider for userNamePasswordValidationMode in the ServiceCredentials for a WCF REST Service if I have a Custom Membership Provider? Is the following route the best to take if this is possible:
Create a custom membership provider that implements Membership Provider.
Create a CustomUserNamePasswordValidator that implements UserNamePasswordValidator and override the Validate Method.
In the Validate method, validate whether a user exists in the database.
Issues I am having are, if I have a login method in my service and it is called from an a web browser with the url http://test.com/service.svc/login, how can I get the username and password. Assume that it the username and password can be typed into a web page or it can come from a smart device application (android, iphone, etc)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够:
[HowToUseNonDefaultMembershipProvider][1] 在步骤 1 中,该页面有两个附加链接,第一个链接显示如何构建成员资格提供程序类,第二个链接显示必要的配置条目。虽然第二个链接讨论指定默认提供程序,但您实际上可以在配置中指定任意数量的提供程序,其中一个恰好是默认提供程序:
现在,在上面链接的示例代码中,您可以在 AuthenticationService_Authenticating 中包含一行像这样的方法:
在您的自定义提供程序类中,您将实现 ValidateUser 方法。这可以包含验证用户名和密码所需的任何逻辑。密码(传递给该方法)。
[1]:http://How:使用 WCF 身份验证服务的非默认成员资格提供程序
You should be able to:
[HowToUseNonDefaultMembershipProvider][1] In Step 1 the page has two additional links, the first shows you how to build the membership provider class, the second shows the config entries necessary. While the second link talks about specifying the default provider you can actually specify any number of providers in the config, one of them would just happen to be the default:
Now in the sample code from the link above you could have a line in the AuthenticationService_Authenticating method like so:
In your custom provider class you would implement the ValidateUser method. This could contain whatever logic necessary to validate the username & password (which are passed to the method).
[1]: http://How to: Use Non-default Membership Provider for WCF Authentication Service