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

How to show a message box from a bash script in linux

linux bash scripting ubuntu gtk

I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.

How to Bind CurrentCell in WPF datagrid using MVVM pattern

c# wpf xaml mvvm datagrid

I am learning WPF MVVM pattern. I am stuck in Binding CurrentCell of datagrid. Basically I need the row index and column index of current cell.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.