在WCF服务使用ASP.NET成员资格提供authentincation [英] Using ASP.NET Membership Provider authentincation in a WCF service
问题描述
有没有使用来自成员提供相同的用户名和密码WCF服务的身份验证的方法吗?如果是这样,它结合它支持?我需要从当前调用服务的用户中提取的配置文件变量。感谢您的帮助。
Is there a way to use the same username and password from the membership provider for a WCF service authentication? if so, which binding does it supports? I need to extract a profile variable from the user currently calling the service. Thanks for any help.
推荐答案
基本上任何约束力接受用户名/密码为邮件安全客户端凭据可以配置为使用ASP.NET成员资格人员。
Basically any binding that accepts username/password as client credentials for message security can be configured to use the ASP.NET membership provider.
看看这个MSDN文档上如何使用WCF ASP.NET成员提供商 - 你需要配置您的键入用户名
Check out this MSDN docs on how to use the ASP.NET Membership provider in WCF - you need to configure your binding for client credentials of type "UserName"
<bindings>
<wsHttpBinding>
<!-- Set up a binding that uses UserName as the client credential type -->
<binding name="MembershipBinding">
<security mode ="Message">
<message clientCredentialType ="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
和使用ASP.NET成员进行用户身份验证的服务:
and the service to use ASP.NET Membership for user authentication:
<serviceBehaviors>
<behavior name="AspNetMembership">
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode ="MembershipProvider"
membershipProviderName ="SqlMembershipProvider"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
当然,你可以选择设置时,他们申请这项服务行为,你的服务!
and of course, you have to apply this service behavior to your services when configuring them!
<services>
<service name="YourService" behaviorConfiguration="AspNetMembership">
....
</service>
</services>
用户名客户端凭据类型由basicHttpBinding的,的wsHttpBinding,NetTcpBinding的支持 - 这样pretty多所有常见的犯罪嫌疑人。
The UserName client credential type is supported by basicHttpBinding, wsHttpBinding, netTcpBinding - so pretty much all the usual suspects.
这篇关于在WCF服务使用ASP.NET成员资格提供authentincation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!