public class MyOwnSqlProvider : SqlMembershipProvider
{
public override bool ValidateUser(string username, string password)
{
System.Diagnostics.Debug.WriteLine(username + " – " + password);
return base.ValidateUser(username, password);
}
}
There we have, I can intercept the calls, add my own rules, etc. The only other change is to the web config to tell the world about the new provider.
<membership defaultProvider="MyAspNetSqlMembershipProvider">
<providers>
<add name="MyAspNetSqlMembershipProvider" type="MyMembershipDemo.Web.MyOwnSqlProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
I’m not suggesting that this removes the need to write your own provider but if, like me, you only want to make a couple of subtle changes then this might save a lot of effort. BTW if you do want to delve deeper into writing your provider then you should take a look at Microsoft’s Provider Toolkit