Solved

Change password in code using asp.net membership

Posted on 2007-11-14
5
8,413 Views
Last Modified: 2013-11-26
I need a quick example of how to change membership user's password in code.  I cannot use the changepassword control
0
Comment
Question by:mugsey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 7

Expert Comment

by:bungHoc
ID: 20279217
Please tell me why you can't use ChangePassword control? AFAIK, that's the simple way to do it.
0
 
LVL 6

Accepted Solution

by:
ventaur earned 500 total points
ID: 20280321
You'll need to know the old password for this to work:

using System.Web.Security;
...

string UserName = User.Identity.Name; // or some other source for the user name
MembershipUser UserToChange = Membership.GetUser(UserName);
UserToChange.ChangePassword(OldPassword, NewPassword);


-----------------------
Regards,
-Matt
0
 
LVL 1

Expert Comment

by:Mayank_Agarwal
ID: 21228426
Thansk this did help me a lot

Are you able to tell me why does the ChangePasswrod control gives "password incorrect or ........" error even if it has successfully changed the password?

Mayank
0
 

Author Comment

by:mugsey
ID: 21228885
Hi

It was my web.config was not configured correctly
0
 
LVL 1

Expert Comment

by:Mayank_Agarwal
ID: 21242721
Can you please clarify what part was wrong with Web.config
here is asnippet of mine
            <membership defaultProvider="CustomizedMembershipProvider">
                  <providers>
                        <add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="myconnString" applicationName="/"
             requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="3"
             enablePasswordReset="true"
             enablePasswordRetrieval="false"/>
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question