Solved

Change password in code using asp.net membership

Posted on 2007-11-14
5
8,407 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi

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

Expert Comment

by:Mayank_Agarwal
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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 video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now