Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change password in code using asp.net membership

Posted on 2007-11-14
5
Medium Priority
?
8,415 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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