Solved

Change password in code using asp.net membership

Posted on 2007-11-14
5
8,410 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
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 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