Validating User/Pass in WCF service using UserNamePasswordValidator Class

Xcantion

New Member
I have created a simple WCF web service that is hosted in an ASP.net Web Application. I am having an issue with Authentication though. I have decided to go with the UserNamePasswordValidator class for authentication. All works pretty well if I hardcode the Username/pass in the validator. Although I want it to be verified through a database. I have created a simple SQL DB with a table for Username and one for Pasword and added a test account into it. How exactly can I authenticate through the DB instead of through a hardcorded string? I have checked MSDN and have found nothing about using a database for auth using this class, only hardcoded string. Also is their a better database I should be using for something like this? The Service will be hosted on the internet and will have many different log-ins since users will be able to create an account when they use my application. Users will only be able to log in through it's clients(mainly a desktop application) and not through the browser. I have checked MSDN and have found nothing about using a database for auth using this class, only hardcoded string.Here is the code I am using for the service validator currently:\[code\]using System;using System.ServiceModel;namespace CustomUsernamePasswordAuth.Service{class UserNamePassValidator : System.IdentityModel.Selectors.UserNamePasswordValidator{ public override void Validate(string userName, string password) { if( userName==null || password==null) { throw new ArgumentNullException(); } if (!(userName == "TestAccount" && password == "password1") ) { throw new FaultException("Incorrect Username or Password"); } } }}\[/code\]
 
Back
Top