当前位置: 首页>>代码示例>>C#>>正文


C# MembershipUser.ResetPassword方法代码示例

本文整理汇总了C#中System.Web.Security.MembershipUser.ResetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipUser.ResetPassword方法的具体用法?C# MembershipUser.ResetPassword怎么用?C# MembershipUser.ResetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Security.MembershipUser的用法示例。


在下文中一共展示了MembershipUser.ResetPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetPassword_OnClick

        protected void ResetPassword_OnClick(object sender, EventArgs e)
        {
            string newPassword = "";

                try
                {

                    u = Membership.GetUser(MemberUserName.Text, false);
                    newPassword = u.ResetPassword(AnswerTextBox.Text);

                    if (newPassword != null)
                    {
                        Msg.Text = "Password reset. Your new password is: " + Server.HtmlEncode(newPassword);
                    }
                    else
                    {
                        Msg.Text = "Password reset failed. Please re-enter your values and try again.";
                    }
                }
                catch (MembershipPasswordException ex)
                {
                    Msg.Text = "Invalid password answer. Please re-enter and try again.";
                    return;
                }
                catch (Exception ee)
                {
                    Msg.Text = ee.Message;
                    return;
                }
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:30,代码来源:Secret_Question.ascx.cs

示例2: SubmitButton_Click

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //string pw = Membership.GeneratePassword(8, 1);
            // u = Membership.GetUser();

               string MembershipUserName = Membership.GetUserNameByEmail(Email.Text.Trim());
               string strmsg = "";

               if (MembershipUserName == UserName.Text.Trim())
               {

               u = Membership.GetUser(UserName.Text.Trim(), false);
               try
               {
                   string newPassword = "";
                   newPassword = u.ResetPassword();

                   string strMailTo = Email.Text.Trim();
                   string strMsgTitle = "Rent-House Password Recovery Details";
                   string strMsgContent = message(Server.HtmlEncode(newPassword), "user's name");

                  int rtn = SendEmail(u.Email, strMsgTitle, strMsgContent);

                  if (rtn == 1)
                   {
                         strmsg = "New password request accepted! Please check your email.";
                   }
                   else
                   {
                         strmsg = "New password request not accepted! Please try again.";
                   }
               }
               catch (MembershipPasswordException ex1)
               {
                   strmsg = "New password request not accepted! Please try again.";
                   return;
               }
               catch (Exception ex2)
               {
                   strmsg = "New password request not accepted! Please try again.";
                   return;
               }
               }
               else
               {
               strmsg = "Enter correct User details!";
               return;
               }
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:49,代码来源:Request_Password.ascx.cs

示例3: ChangePassword

        /// <summary>
        /// Changes password and removes hash from DDS
        /// </summary>
        /// <param name="user"></param>
        /// <param name="newPassword"></param>
        /// <param name="hash"></param>
        /// <returns></returns>
        public bool ChangePassword(MembershipUser user, string newPassword, string hash)
        {
            bool success = false;
            //change password
            if (user != null)
            {
                // reset password to retrieve current password
                string resetPw = user.ResetPassword();
                success = user.ChangePassword(resetPw, newPassword);
                // clean up - remove reset link from dds
                if (!string.IsNullOrEmpty(hash))
                    _resetPasswordRespository.Delete(hash);
            }

            return success;
        }
开发者ID:smchristenson,项目名称:CommerceStarterKit,代码行数:23,代码来源:ResetPasswordService.cs

示例4: ChangePassword

 public void ChangePassword(MembershipUser user, string newPassword)
 {
     var resetPassword = user.ResetPassword();
     if (!user.ChangePassword(resetPassword, newPassword))
         throw new MembershipPasswordException("Could not change password.");
 }
开发者ID:dogbrain,项目名称:MVC3NHibernateNinjectNLog,代码行数:6,代码来源:AspNetMembershipProviderWrapper.cs

示例5: ResetPassword

 public string ResetPassword(MembershipUser user, string passwordAnswer)
 {
     return user.ResetPassword(passwordAnswer);
 }
开发者ID:dogbrain,项目名称:MVC3NHibernateNinjectNLog,代码行数:4,代码来源:AspNetMembershipProviderWrapper.cs

示例6: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            UserAccount ua = new UserAccount();
            ua.GetUserAccountByEmail(email);

            if (ua.UserAccountID == 0)
            {
                ViewBag.Result = Messages.NotFound;
            }
            else
            {
                ua.FailedPasswordAnswerAttemptCount = 0;
                ua.FailedPasswordAttemptCount = 0;
                ua.IsLockedOut = false;
                ua.Update();

                mu = Membership.GetUser(ua.UserName);
                string newPassword = mu.ResetPassword();

                BootBaronLib.Operational.Utilities.SendMail(email, BootBaronLib.Configs.AmazonCloudConfigs.SendFromEmail, Messages.PasswordReset,
                   Messages.UserName + ": " + ua.UserName + Environment.NewLine +
                    Environment.NewLine + Messages.NewPassword + ": " + newPassword +
                    Environment.NewLine +
                Environment.NewLine + Messages.SignIn + ": " + BootBaronLib.Configs.GeneralConfigs.SiteDomain);

                ViewBag.Result = Messages.CheckYourEmailAndSpamFolder;
            }

            return View();
        }
开发者ID:pakoito,项目名称:web,代码行数:30,代码来源:AccountController.cs

示例7: GetRestorePasswordMessage

        private string GetRestorePasswordMessage( MembershipUser user )
        {
            string password;
              string templateFileName;

              try
              {
            try
            {
              password = user.GetPassword();
              templateFileName = "restorePassword.txt";
            }
            catch ( Exception exc )
            {
              log.WarnFormat(
            "First chance exception when tried to get the password for {0} ({1}): {2}",
            user.UserName,
            user.Email,
            exc.Message
              );
              password = user.ResetPassword();
              templateFileName = "resetPassword.txt";
            }
              }
              catch ( Exception exc )
              {
            log.FatalFormat(
              "Can't {0} user password for {1} ({2}): {3}",
              Membership.EnablePasswordRetrieval ? "get" : "reset",
              user.UserName,
              user.Email,
              exc.Message
            );
            throw;
              }

              string templatePath = Path.Combine( HttpRuntime.AppDomainAppPath, "EmailTemplates" );
              templatePath = Path.Combine( templatePath, templateFileName );
              string messageText =
            File.ReadAllText( templatePath )
            .Replace( "<%UserName%>", user.UserName )
            .Replace( "<%Password%>", password )
            .Replace( "<%AdminEmail%>", Settings.Default.AdminEmail );

              return messageText;
        }
开发者ID:new-mikha,项目名称:flytrace,代码行数:46,代码来源:restorePassword.aspx.cs

示例8: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            var ua = new UserAccount();
            ua.GetUserAccountByEmail(email);

            if (ua.UserAccountID == 0)
            {
                ViewBag.Result = Messages.NotFound;
            }
            else
            {
                ua.FailedPasswordAnswerAttemptCount = 0;
                ua.FailedPasswordAttemptCount = 0;
                ua.Update();

                _mu = Membership.GetUser(ua.UserName);

                if (_mu != null)
                {
                    string newPassword = _mu.ResetPassword();

                    _mail.SendMail(AmazonCloudConfigs.SendFromEmail, email, Messages.PasswordReset,
                        string.Format("{0}: {1}{2}{2}{3}: {4}{2}{2}{5}: {6}",
                            Messages.UserName, ua.UserName, Environment.NewLine,
                            Messages.NewPassword, newPassword, Messages.SignIn, GeneralConfigs.SiteDomain));
                }

                ViewBag.Result = Messages.CheckYourEmailAndSpamFolder;
            }

            return View();
        }
开发者ID:dasklub,项目名称:kommunity,代码行数:32,代码来源:AccountController.cs

示例9: ChangePassword

 /// <summary>
 /// Change user password
 /// </summary>
 /// <param name="user">Membership user</param>
 /// <param name="newPassword">new password</param>
 /// <returns>Return true if password changed</returns>
 public bool ChangePassword(MembershipUser user, string newPassword)
 {
     return user.ChangePassword(user.ResetPassword(), newPassword);
 }
开发者ID:ognjenm,项目名称:egle,代码行数:10,代码来源:EviivoMembership.cs

示例10: ChangePassword

 public void ChangePassword(MembershipUser membershipUser, string newPassword)
 {
     string tempPassword = membershipUser.ResetPassword();
     membershipUser.ChangePassword(tempPassword, newPassword);
 }
开发者ID:fschwiet,项目名称:FschwietMembershipStarterKit,代码行数:5,代码来源:AspNetMembershipProviderWrapper.cs

示例11: ChangeUserPassword

        public static bool ChangeUserPassword(MembershipUser user, string newPassword, string verificationId)
        {
            try
            {
                string newPass = string.Empty;
                try
                {
                    newPass = user.ResetPassword();
                }
                catch (Exception exception)
                {
                    if (exception.Message.Contains("user account has been locked out"))
                    {
                        user.UnlockUser();
                        newPass = user.ResetPassword();
                    }
                    else
                        ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
                bool changed = user.ChangePassword(newPass, newPassword);
                var tempUser = GetMember(user.UserName);

                SendEmailForPasswordChanged(user.Email, tempUser.DerbyName);
                var dc = new ManagementContext();
                var verify = dc.EmailVerifications.Where(x => x.VerificationId == new Guid(verificationId)).FirstOrDefault();
                if (verify != null)
                {
                    dc.EmailVerifications.Remove(verify);
                    int c = dc.SaveChanges();
                }
                return changed;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:39,代码来源:User.cs

示例12: SendResetEmail

            public void SendResetEmail(MembershipUser user)
            {
            //The URL to login
            string domain = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + HttpRuntime.AppDomainAppVirtualPath;

            //link to send
            string link = domain + "/Home/PassReset?userName={0}&oldPassword={1}";
            link = link.Replace("//", "/");

            string newPassword = user.ResetPassword();
            link = string.Format(link, user.UserName, newPassword);

            var body = @"<html>
            <head>
            <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">
            <title>ForexBox</title>
            <style type=""text/css"">
            body, #header h1, #header h2, p {margin: 0; padding: 0;}
            </style>
            </head>
            <body>
            <table width=""100%""  cellpadding=""0"" cellspacing=""0"" style=""font-size:12px;line-height:22px;font-family:Arial,sans-serif;color:#555555;table-layout:fixed"">
            <tbody><tr><td style=""background-color:#ededed;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <table rules=""none"" frame=""border"" width=""400"" align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""font-size:12px;border-collapse:collapse;border:0px solid #e4e2e4;line-height:22px;font-family:Arial,sans-serif;color:#555555;border-spacing:0;border:solid 1px #ededed;cursor:default;"">
            <tbody><tr><td valign=""top"" style=""background-color:#ededed;border-collapse:collapse;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""margin-top:24px;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <tbody><tr>
            <td valign=""top"" width=""150"" style=""font-size:25px; text-shadow: 1px 1px white;font-weight:bold;font-family:Tahoma,sans-serif;color:#333;padding-bottom:10px""><a style=""color:#666;font-size:24px"">Forex</a><a style=""color:#F84040;font-size:24px"">Box</a></td>
            <td valign=""top"" align=""right"" style=""text-align:right;font-size:12px;line-height:16px;font-family:Arial,sans-serif;color:#3fb6dd;padding-top:6px"">
            <a style=""color:#666;font-size:14px; text-shadow: 1px 1px white"" href=""http://4rexbox.com"" target=""_blank"">Главная</a>&nbsp;&nbsp;&nbsp;
            <a style=""color:#666;font-size:14px; text-shadow: 1px 1px white"" href=""http://4rexbox.com/Home/News"" target=""_blank"">Новости</a>&nbsp;&nbsp;&nbsp;
            </td>
            </tr>
            </tbody></table>
            </td></tr>
            <tr><td valign=""top"" bgcolor=""#ffffff"" style=""border-top:solid 1px #e0e0e0;background-color:#ffffff;border-collapse:collapse;color:#555555;font-family:Arial,sans-serif;font-size:10px;line-height:18px"">
            <table width=""400"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""40"">&nbsp;</td></tr></tbody></table>
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"">
            <tbody><tr><td valign=""top"" style=""color:#666;font-family:Arial,sans-serif;font-size:14px;line-height:20px"">
            <span style=""font-size:17px;line-height:10px;font-weight:bold;color:#666;text-align:center"">
            Здравствуйте уважаемый(мая)

            "
                + user.UserName +

            @"
            </span>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            Вы отправили заявку для смены пароля<br> от Вашего кабинета ForexBox.
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            Пройдите по следующей <a href=" + link + @">ссылке</a> <br>
            Или скопируйте ее в адрессную строку:<br><br>
            <i>" + link + @"</i><br><br>
            И в появившейся странице введите Ваш новый пароль.<br>

            </td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""20""></td></tr></tbody></table>
            </td></tr>
            <tr><td valign=""top"" bgcolor=""#d9ecff"" style=""background-color:#fafafa;border-top:solid 1px #e0e0e0;border-bottom:solid 1px #e0e0e0;color:#777777;font-family:Arial,sans-serif;font-size:14px;line-height:19px"">
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""20""></td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center""><tbody><tr><td style=""color:#666;font-family:Arial,sans-serif;font-size:14px;font-weight:normal;line-height:19px"">
            Если Вы не отправляли заявку для смены пароля,<br>
            то просто проигнорируйте это письмо.<br><br>
            Если у Вас есть какие-либо вопросы, пожалуйста,<br>
            обращайтесь к нам в тех-поддержку.<br><br>
            Еще раз благодарим за сотрудничество, и желаем<br>
            успешной торговли вместе с ForexBox!<br>
            </td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            </td></tr>
            <tr><td valign=""top"" style=""background-color:#ededed;border-collapse:collapse;color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px;border-top:solid 1px #e0e0e0"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px""><tbody><tr>
            <td valign=""top"" style=""font-size:10px;border-top-color:#eeeeee;line-height:18px;font-family:Arial,sans-serif;color:#777777;border-top-style:solid;border-top-width:1px"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px"">
            <tbody><tr>
            <td valign=""top"" width=""160"" style=""color:#999999;font-family:Arial,sans-serif;font-size:11px;line-height:16px"">
            <b style=""font-weight:bold;color:#333"">«ForexBox»</b>
            <br><a href=""http://4rexbox.com"" style=""color:#3279bb;text-decoration:underline"" target=""_blank"">www.4rexbox.com</a>
            <br><a style=""color:#3279bb;text-decoration:underline"">[email protected]</a>
            </td>
            </tr>
            </tbody></table>
            <table width=""450"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""40""></td></tr></tbody></table>
            </td>
            </tr></tbody></table>
            </td></tr>
            </tbody></table>
            </td></tr></tbody></table>
            </body>
            ";

            AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
            (System.Text.RegularExpressions.Regex.Replace(body, @"<(.|\n)*?>", string.Empty), null, "text/plain");

            AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(body, null, "text/html");
            SendMail(user.Email, "Password reset", body);

            /*
            var message = new MailMessage("[email protected]", user.Email)
            {
//.........这里部分代码省略.........
开发者ID:riseandcode,项目名称:FxGraphsRepository,代码行数:101,代码来源:HomeController.cs

示例13: SendResetEmail

        public void SendResetEmail(MembershipUser user)
        {
            //The URL to login
            if (HttpContext.Request.Url == null) return;
            var domain = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) +
                            HttpRuntime.AppDomainAppVirtualPath;

            //link to send
            var link = domain + "/Account/Logon";

            var body = "<p> Dear " + user.UserName + ",</p>";
            body += "<p> Your Orion password has been reset, Click " + link + " to login with details below</p>";
            body += "<p> UserName: " + user.UserName + "</p>";
            body += "<p> Password: " + user.ResetPassword() + "</p>";
            body += "<p>It is recomended that you change it after logon.</p>";
            body += "<p>If you did not request a password reset you do not need to take any action.</p>";

            var plainView = AlternateView.CreateAlternateViewFromString
                (System.Text.RegularExpressions.Regex.Replace(body, @"<(.|\n)*?>", string.Empty), null, "text/plain");

            var htmlView = AlternateView.CreateAlternateViewFromString(body, null, "text/html");

            var message = new MailMessage("haithem-araissia.com", user.Email)
                {
                    Subject = "Password Reset",
                    BodyEncoding = System.Text.Encoding.GetEncoding("utf-8"),
                    IsBodyHtml = true,
                    Priority = MailPriority.High,
                };

            message.AlternateViews.Add(plainView);
            message.AlternateViews.Add(htmlView);

            var smtpMail = new SmtpClient();
            var basicAuthenticationInfo = new System.Net.NetworkCredential("[email protected]",
                                                                           "haithem759163");
            smtpMail.Host = "mail.haithem-araissia.com";
            smtpMail.UseDefaultCredentials = false;
            smtpMail.Credentials = basicAuthenticationInfo;
            try
            {
                smtpMail.Send(message);
            }
            catch (Exception)
            {
                RedirectToAction("Index", "Home");
                throw;
            }
        }
开发者ID:haithemaraissia,项目名称:Rental,代码行数:49,代码来源:AccountController.cs

示例14: ResetPassword

 public void ResetPassword(MembershipUser membershipUser)
 {
     var newPassword = membershipUser.ResetPassword();
     var body = string.Format(@"This is a password reset notification from LogWhatever.com. Your password has been reset to <b>{0}</b>. You will need to use this new password when you next log on.", newPassword);
     MailSender.Send(ConfigurationProvider.FromEmailAddress, membershipUser.UserName, "LogWhatever Password Reset", body);
 }
开发者ID:chrisharrington,项目名称:LogWhatever,代码行数:6,代码来源:AspMembership.cs

示例15: GenerateFor

        //Return the passwordResetRequest object for the given user
        //Sends an email to the user with a link to the PasswordResetRequest's page
        public static PasswordResetRequest GenerateFor(MembershipUser user)
        {
            PasswordResetRequest resetReq = null;
            using (DREAMContext db = new DREAMContext())
            {
                resetReq = new PasswordResetRequest();
                {
                    resetReq.ID = PasswordResetRequest.GenerateNewID();
                    resetReq.UserID = (Guid)user.ProviderUserKey;
                }
                db.SaveChanges();

                String newPassword = user.ResetPassword();

                SendEmail("[email protected]", user.Email, "", "", "DREAM Password Reset", newPassword);

                return resetReq;
            }
        }
开发者ID:jneufeld,项目名称:cs319,代码行数:21,代码来源:PasswordResetRequest.cs


注:本文中的System.Web.Security.MembershipUser.ResetPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。