Hi Friends,
I have to authenticate my wcf service using CustomUserNameValidator, but its never gettinbg hit .
Please look at my below code.
//Client Side
RESTSVCClient oClient = new RESTSVCClient();
oClient.ClientCredentials.UserName.Password = "Suresh";
oClient.ClientCredentials.UserName.Password = "12345";
//In WCF Service I have a class as below
public class CustomUserNameValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "suresh" && password == "12345"))
{
throw new FaultException("Unknown Username or Incorrect Password");
}
}
}
In WCF Web.config
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="RESTFULLSVC.CustomUserNameValidator,RESTFULLSVC"/>
</serviceCredentials>
</behavior>
Pls advice , how do i fire the Validate(string userName, string password) ?