Site Search:
Sign in | Join | Help
4Penny.net

ASP.NET

Notes, Tricks and Tips on ASP.NET Coding

ASP.NET Membership Password Reset

Someone wanted to reset their password for their aspnet membership site. Since I didnt have the source code only the database information, I had to create a new project with only a page setup for password changing. Make sure you set the new projects web.config file to match the role provider information for the database currently used.

<connectionStrings>

<add name="name" connectionString="Data Source=server;User Id=userid;Password=psswrd;Initial Catalog=database" providerName="System.Data.SqlClient" />

</connectionStrings>

<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">

<providers>

<clear/>

<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"

connectionStringName="name" applicationName="name" enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

requiresUniqueEmail="true"

minRequiredPasswordLength="4"

minRequiredNonalphanumericCharacters="0"

passwordFormat="Hashed"/>

</providers>

</membership>

 

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

If TextBox2.Text = TextBox3.Text Then

Dim strun As String = TextBox1.TextDim user As MembershipUser = Membership.GetUser(strun)

user.UnlockUser()

Dim oldpswd As String = user.ResetPassword()

Membership.GetUser(strun).ChangePassword(oldpswd, TextBox2.Text)

End If

End Sub

 

Comments

No Comments

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.