I will appreciate if I can have a hello world example of how can I make a client have to supply a specific username and password in order to consume a wcf service. I am self hosting my service therefore it is not on IIS.
I have Server A and Client B. They are different computers on the same network.
I am using the default Service1 class that visual studio creates when creating a new WCF Class Library. So I create that service on Server A.
Then on Client B I add a service reference to that address which happens to be:
http://10.10.1.135:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex
(Client B is a console app)
In order to consume that service I have to do:
static void Main(string[] args)
{
ServiceReference1.Service1Client svc = new ServiceReference1.Service1Client();
svc.ClientCredentials.Windows.ClientCredential.UserName = "MyUserName";
svc.ClientCredentials.Windows.ClientCredential.Password = "MyPassword";
var a = svc.GetData(5); // consume the service
}
Note I had to use the username and password of the domain user. How can I do something similar using a custom password? I do not want to have to provide those cridentials and I also do not want to create new users on windows. It will be nice if I could validate against a database.
Just Google it:
http://codebetter.com/petervanooijen/2010/03/22/a-simple-wcf-service-with-username-password-authentication-the-things-they-don-t-tell-you/
Simple ones:
http://blogs.msdn.com/b/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx
http://www.codeproject.com/Articles/431358/Selfhosted-Secure-WCF-by-Id-password-custom-valida