Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:49:18+00:00 2026-05-14T16:49:18+00:00

I have a new table that hold old passwords, I need to check if

  • 0

I have a new table that hold old passwords, I need to check if there is a match.

If there is a match I need the ChangePassword contol to NOT change the password. I need to tell the user that this password was used and pic a new one.

I can’t seem to be able to interrupt the control from changing the password.
Maybe I am using the wrong event.

Here is a piece of my code, or how I wish it would work.
I appreciate all your help.

protected void ChangePassword1_ChangedPassword(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser();
        string usrName = "";
        if (user != null)
        {
            string connStr = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
            SqlConnection mySqlConnection = new SqlConnection(connStr);
            SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
            mySqlCommand.CommandText = "Select UserName from OldPasswords where UserName = 'test'";
            mySqlConnection.Open();
            SqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(CommandBehavior.Default);
            while (mySqlDataReader.Read())
            {
                usrName = mySqlDataReader["UserName"].ToString();
                if (usrName == user.ToString())
                {

                    Label1.Text = "Match";
                }
                else
                {
                    Label1.Text = "NO Match!";
                }
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:49:18+00:00Added an answer on May 14, 2026 at 4:49 pm

    You are overriding the wrong method, Steve. You want to override the cancellable ChangingPassword.

    Try this:

    protected void ChangePassword1_ChangingPassword(object sender, LoginCancelEventArgs e)
    {
        // do your lookup here, 
        bool passwordHasBeenPreviouslyUsed = true;
    
        if (passwordHasBeenPreviouslyUsed)
        {
            e.Cancel = true;
            // notify of error
            return;
        }
    
    }
    

    And, as per previous Q/A sessions, You should NEVER EVER EVER store a user’s password1. Go to the membership table and get the salt and use that to hash the incoming password to compare to the already salt-hashed values you have stored in your lookup table.

    Good luck.

    (1) – how tenable would your position be when the CEO finds out that his password has been stored in an exploitable format? There is a level of trust given to the black mages that are us and that trust carries it’s own risks. Be aware of them. 😉

    EDIT:

    A working example:

    ChangePassword.aspx

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Diagnostics"%>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void ChangePassword1_ChangingPassword(object sender, LoginCancelEventArgs e)
        {
            // works for me!
            Debugger.Break();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ChangePassword ID="ChangePassword1" runat="server" OnChangingPassword="ChangePassword1_ChangingPassword">
            </asp:ChangePassword>
        </div>
        </form>
    </body>
    </html>
    

    Update:
    You may also be interested in simply defining a handler in a higher scope that will watch all password activity:

    consider this

    public void SetupPasswordActionHook()
    {
    
        //Occurs when a user is created, a password is changed, or a password is reset.
        Membership.ValidatingPassword += Membership_ValidatingPassword;
    }
    
    void Membership_ValidatingPassword(object sender, ValidatePasswordEventArgs e)
    {
    
        // Gets a value that indicates whether the System.Web.Security.MembershipProvider.ValidatingPassword event is being raised during a 
        // call to the System.Web.Security.MembershipProvider.CreateUser() method.
    
        // true if the System.Web.Security.MembershipProvider.ValidatingPassword event is being raised during a call to the 
        // System.Web.Security.MembershipProvider.CreateUser() method; otherwise, false.
        bool isNewUser = e.IsNewUser;
    
        // Gets the password for the current create-user, change-password, or reset-password action.
    
        // The password for the current create-user, change-password, or reset-password action.
        string password = e.Password;
    
        // Gets the name of the membership user for the current create-user, change-password, or reset-password action.
    
        // The name of the membership user for the current create-user, change-password, or reset-password action.
        string username = e.UserName;
    
        // Gets or sets a value that indicates whether the current create-user, change-password, or reset-password action will be canceled.
    
        // true if the current create-user, change-password, or reset-password action will be canceled; otherwise, false. The default is false.
        e.Cancel = true;
    
        // Gets or sets an exception that describes the reason for the password-validation failure.
    
        // An System.Exception that describes the reason for the password-validation failure.
        e.FailureInformation = new Exception("This is why I failed your password");
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several (old) Drupal-sites that need to be replaced with one single new
I have a table that we just enabled FileStreams on. We created a new
I have a table into which new data is frequently inserted. I need to
I am new to SQL, and have two tables that hold data(I am using
I have a table that have a property named recordsource that will hold the
I have an a new table with the column below: id , name ,
I have created a new table including a column note. The default is varchar(255)
I have the following code which creates a new table. var html = '<table>';
Most of my content is in a new table I have added to JOOMLA
say I have a UITableView and upon selecting a new table row (thus firing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.