public override void Validate(string userName, string password) { //validate arguments if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException(userName); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException(password); } //check if user is not test if (userName!="test" || password != "test") { throw new FaultException("Incorrect Username or Password"); } }
<serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TruckService.ServiceLibrary.TruckService,TruckService.ServiceLibrary" /> </serviceCredentials> <security mode="TransportWithMessageCredential"> <message clientCredentialType="UserName"/> </security>
using (ServiceReference1.TruckServiceClient obj = new ServiceReference1.TruckServiceClient()) { obj.ClientCredentials.UserName.UserName = "test"; obj.ClientCredentials.UserName.Password = "test"; string returndata = obj.GetData(100); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)