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 ThenDim 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