We have implemented a user membership provider and changed the password on the web page that uses this provider. The ChangePassword method in this class of the membership provider checks some business logic about the strength and validity of the password by connecting to an external web service. Webservice has the ability to return exactly what is wrong with the new password, if there is one (problems with duration, special character, etc.).
Now the signature of the ChangePassword method, which must be canceled by the customer, is as follows:
public override bool ChangePassword(string username, string oldPassword, string newPassword)
Thus, although I know the exact problem with the new password that the user provides, I canβt display it on the web page, because I can only return true or false from this method, and then changes the password and takes care of it own magic depending on the logical return value. I can OnChangePasswordError on the ChangePassword control's OnChangePasswordError event to show a static error message, or I can even set the FailureText property of this control to some string with a hard code when an error occurs, but I cannot provide the user with something that does not exactly match the password, which they provided.
protected void OnPasswordChangeError(object sender, EventArgs e) { throw new MembershipPasswordException("Tell user what exactly is wrong with the password they supplied"); }
The MembershipProvider class has a ValidatingPassword event that is raised before the password is changed, and here I can throw an exception by checking if the password meets the criteria, but still this exception does not seem to be passed to the ChangePassword control. Here is the code for the ValidationPassword eventHandler:
void MyMembershipProvider_ValidatingPassword(object sender, ValidatePasswordEventArgs e) {
how to send specific information from the ChangePassword method of the membership provider class to the ChangePassword control to display the correct error messages to the user, not static / hard-coded with errors? Is there a way to connect ValidatePasswordEventArgs to EventArgs in EventHandler for the OnChangePassword method so that I can get error information in the ChangePassword control?
From my initial research this is not possible. Although I feel that the MS team would not lose sight of this, and there must be a way.
A few pointers:
MemberhipUser.ChangePassword fails without warning http://forums.asp.net/t/983613.aspx
asp.net-membership membership-provider asp.net-webcontrol
desigeek
source share