WCF and Custom Soap Authentication

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.

Answers


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 
    }
}

Need Your Help

When using "bundle" packaging with maven-bundle-plugin goals are executed twice

java maven maven-bundle-plugin

I have a (simple) maven project with packaging type "bundle" using org.apache.felix:maven-bundle-plugin:2.5.4. It produces a correct OSGI bundle jar. However i observe that all goals are executed at

Using a tsql MERGE statement in SSIS to copy data between databases

sql-server ssis sql-server-2012 etl

I am trying to do something which I think should be very straightforward, but I can't see how to actually do it.