Here, I will talk about authenticating a Windows Communication Service by user name and password.
I describe this as Custom Authentication. There are a few more options for authenticating a WCF service. We will however discuss only custom authentication.
The following describes how to set up a WCF service to authenticate by user name and password.
Create a WCF service application using Visual Studio as in the following:
To authenticate the service we need to use the UserNamePasswordValidator base class that validates the user name and password.
So, create a class called UserNamePasswordValidator as shown below.
Modify the web configuration file as in the following:
Here, I have configured it for basicHttpBinding with security mode TransportWithMessageCredential.
You can use wsHttpBinding as well. But, right now I guess it is not supported by Windows 8 store applications. So, use basicHttpBinding with security level "Message".
Also, in the UserNameAuthentication section set UserPasswordValidationMode to "Custom" and the custom class you created for authenticating the service and the assembly name of your application that contains the custom authentication class.
Adding service reference to the client project
Calling service method with passing credentials
Service1Client c = new Service1Client ();
c.ClientCredentials.UserName.UserName = "[email protected]";
c.ClientCredentials.UserName.Password = "[email protected]";
var t = await c. GetData (1);
So, it will authenticate the service call by using credentials and send the results back to the client.


Aravind BsPosted May 20, 2017, 11:58 PM EDT
Https://www.youtube.com/channel/UCN09Z5u6ypUvdxQkp6y2oFg
narasimhulu pPosted Apr 21, 2016, 10:57 PM EDT
It shows error
Vithal WadjeTOP 100Posted Sep 25, 2014, 10:20 AM EDT
great one thanks for sharing
VenkiPosted Apr 18, 2014, 11:29 PM EDT
nice article
Ch HassanPosted Apr 10, 2014, 11:47 PM EDT
which authentication option will use for this type when host on iis ?
Jeetendra GundTOP 100Posted Jan 27, 2014, 7:24 AM EST
Good One Thanks Sir..its helpful