Friday, July 10, 2009

How to create custom change password control

protected void btnChangePassword_Click(object sender, EventArgs e)
{
string UserName = HttpContext.Current.User.Identity.Name;
DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);
DotNetNuke.Security.Membership.MembershipProvider membershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();
if (membershipProvider.PasswordFormat == DotNetNuke.Security.Membership.PasswordFormat.Encrypted)
{
string oldPassword = DotNetNuke.Entities.Users.UserController.GetPassword(ref userInfo, userInfo.Membership.PasswordAnswer);
if (oldPassword == txtOldPassword.Text)
{
string newPassword = txtNewPassword.Text.Trim();//DotNetNuke.Entities.Users.UserController.GeneratePassword(membershipProvider.MinPasswordLength);
DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, newPassword);
txtOldPassword.Text = "";
txtNewPassword.Text = "";
txtOldPassword.Focus();
lblmsg.Text = "Password changed successfully.";
}
else
{
lblmsg.Text = "OldPassword did not match.";
}
}
}

7 comments:

  1. Hi, Firoz,

    Nice post,thanks for sharing this information.Looking forward similar posts .

    Dotnetnuke developers

    ReplyDelete
  2. this is really nice to read..informative post is very good to read..thanks a lot!
    jiofi 2 settings

    ReplyDelete
  3. There's definitely a great deal to find out about this topic. I love all of the points you've made. This was an extremely wonderful article. Thanks for supplying this info. Check out this article for more info about DotNetNuke Development - A Cost Effective Option For Enterprise.

    ReplyDelete
  4. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    DotNet Nuke training in
    Electronic City

    ReplyDelete
  5. Great post, keep on sharing such amazing posts!JioFiLocalHtml

    ReplyDelete