WCF和自定义SOAP验证 [英] WCF and Custom Soap Authentication
问题描述
我开发使用WCF揭露,为客户的WebService端点的服务器应用程序。我想通过将使用通过SOAP头传递的用户名和密码,一个简单的自定义提供来实现认证。我知道如何设置的用户名和密码,在客户端上送的,我只是想知道如何拉的用户名和密码了SOAP头在服务器端。任何帮助将大大AP preciated。
I am developing a server application using WCF to expose WebService endpoints for clients. I want to implement authentication through a simple custom provider that will use the username and password passed through the SOAP headers. I know how to set the user name and password to be sent on the client, I just want to know how to pull the username and password out of the SOAP header on the server side. Any help would be greatly appreciated.
推荐答案
您需要在服务行为,以指定的用户名和密码验证
You need to specify the username and password validator in the service behavior
<behavior name="MyServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyNamespace.MyUserNamePasswordValidator, MyDll" />
</serviceCredentials>
</behavior>
您可以从MyUserNamePasswordValidator类访问用户名和密码
you can access the user name and password from MyUserNamePasswordValidator class
public class MyUserNamePasswordValidator : UserNamePasswordValidator
{
public override void Validate( string userName, string password )
{
// valid your password here
}
}
这篇关于WCF和自定义SOAP验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!