Click here to Skip to main content
15,891,747 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
C#
oClient.ClientCredentials.UserName.Password = "Suresh";
 oClient.ClientCredentials.UserName.Password = "12345";


//In WCF Service I have a class as below

C#
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

XML
<security mode="Message">
            <message clientCredentialType="UserName" />
</security>


XML
<behavior name="ServiceBehaviour">
         <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
         <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
         <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
         <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) ?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900