Reputation: 261
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.
Upvotes: 3
Views: 2836
Reputation: 26668
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>
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
}
}
Upvotes: 3