Membership: Update Password MembershipUser (ChangePassword)

by Pieter Brinkman 13. January 2009 04:32

You can change the password of a MembershipUser object in C# with the ChangePassword method. The only problem of this method is that it needs the old password(string) as input parameter and I only have the hashed version off the password. To get the old password you can user the MembershipUser.ResetPassword() method. This method will reset the password and returns the new password as string.

 

MembershipUser user = Membership.GetUser(userNameTxt.Text);
user.ChangePassword(user.ResetPassword(), passwordTxt.Text);

 

Don't for get to check that the enablePasswordReset setting is true in the web.config.

 

    <membership>
      <providers>
        <remove name="AspNetSqlMembershipProvider" />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="SiteSqlServer"
        enablePasswordRetrieval="false"
        enablePasswordReset="true"
        requiresQuestionAndAnswer="false"
        applicationName="/"
        requiresUniqueEmail="false"
        minRequiredPasswordLength="3"
        minRequiredNonalphanumericCharacters="0"
        passwordFormat="Hashed"
        maxInvalidPasswordAttempts="5"
        passwordAttemptWindow="10"
        passwordStrengthRegularExpression=""/>
      </providers>
    </membership>

 

Goodluck!

Tags: , ,

ASP.Net

Asp.Net Membership: Set url to the login page

by Pieter Brinkman 4. December 2008 08:46

The loginstatus control doesn't have a property to set the url of the login page. You need to set this URL in the web.config of your application.

Insert the login URL between the authentication node of the web.config. So it looks like this

<authentication mode="Forms">
 <forms loginUrl="~/pages/login.aspx" />
</authentication>

Change the value of the loginUrl to your login page.

Tags: , ,

ASP.Net

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am a .NET Software Engineer for Achmea IT in De Meern, The Netherlands. My interests are mainly web applications created with ASP.NET, MSSQL and Silverlight.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

RecentComments

Comment RSS

Most comments

club penguin cheats club penguin cheats
4 comments
us United States
Web Design Company Web Design Company
2 comments
Web design Web design
2 comments
gb United Kingdom