force change password

Hello,
I want to force user to change his password in first login , Is there any idea ?

regards,
2 people have
this question
+1
Reply
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Create a column in a database table indicating if and when a particular user has changed the password.

    Declare a code file that looks as follows;


    namespace MyCompany.Web
    {
    public partial class PageBase : System.Web.UI.Page
    {

    . . . . . .


    In the partial class override method OnLoad.

    Execute a a query against your table to verify if the user's password needs to be changed. If so then redirect to a custom page that allows user to change the password.

    Class PageBase is the base class of all pages. Therefore users will not be able to use any application pages unless the password has been changed.

    Make sure that you "redirect" code does not do so infinitely on the "Change Password" page.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • How to redirect user to "Change Password" form (My Account form)? There is no such aspx file.
    I have created OnLoad method but how can I redirect to My Account? Please, a little bit detailed answer.
    Tnx.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I have found a solution so here it is for those who are struggling with this functionality. This is not so elegant solution (because you have to enter it after each generation of COT project). If someone wants to share better solution, please do.

    First, you need to override OnLoad method in App_code/Web/PageBase.cs file. Enter:

    protected override void OnLoad(EventArgs e)
    {
    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
    System.Web.Security.MembershipUser usercp = System.Web.Security.Membership.GetUser();
    if (usercp.LastPasswordChangedDate == usercp.CreationDate && HttpContext.Current.Request.Url.LocalPath != "/YourProject/Pages/Home.aspx")
    {
    Response.Redirect("~/Pages/Home.aspx");
    }
    }
    }


    Replace YourProject with the name of your project.

    Then, enter following code in PageLoad method in Home.aspx.cs or in control (if control is under Home.aspx file):


    System.Web.Security.MembershipUser usercpc = System.Web.Security.Membership.GetUser();
    if (usercpc.LastPasswordChangedDate == usercpc.CreationDate)
    {
    Page.ClientScript.RegisterStartupScript(GetType(),"changepass","function myAlert(){Web.DataView.showMessage(\"You need to change initial password!\")};setTimeout('myAlert()',10);",true);
    }


    Hope this will help someone.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Thanks Uremovic for the work you did here which I've recently found very useful in implementing similar functionality.

    I made a little amendment to your method. Rather than redirect to Home.aspx, I created a dedicated PasswordReset.aspx page with the necessary control to facilitate the coding.

    I used the built-in MyProfile controller (with some modifications) for the password change so I can have a consistent look and feel.

    Below is my PasswordReset control. Hope this continues to make life easier for others. Cheers.

    You must change your password now!

    Click the button to change password

    CHANGE PASSWORD >>
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated