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


C# MembershipUser.UnlockUser方法代码示例

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


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

示例1: Unlock

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

示例2: Unlock

 /// <summary>
 /// Unlocks a MembershipUser
 /// </summary>
 /// <param name="user">The user.</param>
 public static void Unlock(MembershipUser user)
 {
     if (user.IsLockedOut) {
         user.UnlockUser();
         Log.Write("Administration", "Unlocked user " + user.UserName);
     }
 }
开发者ID:simonegli8,项目名称:Silversite,代码行数:11,代码来源:Persons.cs

示例3: AutoUnlockUser

 private static bool AutoUnlockUser(MembershipUser aspNetUser)
 {
     if (Host.AutoAccountUnlockDuration != 0)
     {
         if (aspNetUser.LastLockoutDate < DateTime.Now.AddMinutes(-1*Host.AutoAccountUnlockDuration))
         {
             //Unlock user in Data Store
             if (aspNetUser.UnlockUser())
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:revellado,项目名称:privateSocialGroups,代码行数:15,代码来源:AspNetMembershipProvider.cs

示例4: gviewUsers_RowCommand

        protected void gviewUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                HiddenUserName.Value = e.CommandArgument.ToString();
                if (e.CommandName == "Edit")
                {
                    lblEditPopupMsg.Text = "";
                    // to show the edit user popup
                    UpdateUserModalPopupExtender.Show();
                    // to fet the user details and fill them
                    objMembershipUser = Membership.GetUser(HiddenUserName.Value);
                    chkStatus.Checked = objMembershipUser.IsApproved;
                    txtUsername.Text = HiddenUserName.Value;
                    txtEmail.Text = objMembershipUser.Email.ToString();
                    UserInfos objUserInfos = UserInfo.SelectByField("UserId", objMembershipUser.ProviderUserKey.ToString(), ConnectionString);
                    if (objUserInfos.Count > 0)
                    {
                        txtEFName.Text = objUserInfos[0].FirstName;
                        txtELName.Text = objUserInfos[0].LastName;
                        txtEAddress1.Text = objUserInfos[0].Address1;
                        txtEAddress2.Text = objUserInfos[0].Address2;
                        txtEWPhone.Text = objUserInfos[0].WorkPhone;
                        txtECellPhone.Text = objUserInfos[0].CellPhone;
                        txtECity.Text = objUserInfos[0].City;
                        txtEState.Text = objUserInfos[0].State;
                        txtECountry.Text = objUserInfos[0].Country;
                        txtEPCode.Text = objUserInfos[0].PostalCode;
                    }
                }
                if (e.CommandName == "Delete")
                {
                    ViewState["UserName"] = e.CommandArgument.ToString();
                    DeleteUserModalPopupExtender.Show();
                }

                if (e.CommandName == "Reset Password")
                {
                    // to change the provider for security purpose use temporary provider
                    MembershipProvider Mp = Membership.Providers["MPforResetPwd"];
                    MembershipUser Mu = Mp.GetUser(HiddenUserName.Value, true);
                    string password = Mu.ResetPassword();
                    //message body
                    StringBuilder body = new StringBuilder();
                    body.Append("<HTML><BODY>");
                    body.Append("<table width=\"100%\"><tr><td align=\"left\" colspan=\"3\" style=\"height:4px; color:green;\"><h3></h3> <td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\"> Hi&nbsp;" + Mu.UserName.ToString() + ",</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">Welcome to 1Point</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("\n<tr><td >Your new Password : &nbsp;&nbsp;" + password + "</td></tr> <tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">You can login in to your account at:</td></tr>");
                    body.Append("<tr><td colspan=\"3\"><a href=\"" + ConfigurationManager.AppSettings["LoginUrl"] + "\">Login</a></td></tr>");
                    body.Append("<tr><td colspan=\"3\"></td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">If there's anything we can do to help, please get in touch.</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">Regards,</td></tr>");
                    body.Append("<tr><td colspan=\"3\">1Point team</td></tr>");
                    body.Append("<tr><td colspan=\"3\">" + ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').GetValue(0) + "</td></tr>");
                    body.Append("<tr></tr>");
                    body.Append("<tr><td colspan=\"3\" style=\"color:red;\">This is an automated Email, please don't Reply.</td></tr>");

                    MailMessage SendMessageToUser = new MailMessage();
                    SendMessageToUser.To.Add(Mu.Email.ToString());
                    SendMessageToUser.Body = body.ToString();
                    SendMessageToUser.Subject = "Your new password";
                    SendMessageToUser.IsBodyHtml = true;
                    //add cc of superadmin emails
                    ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').ToList().ForEach(delegate(string mail) { SendMessageToUser.CC.Add(mail); });
                    SmtpClient SmtpMail = new SmtpClient();
                    SmtpMail.Send(SendMessageToUser);
                    lblMainMsg.Style.Add("color", "Green");
                    lblMainMsg.Text = "Your new password has been emailed to  " + Mu.Email.ToString();
                }
                if (e.CommandName == "Unlock")
                {
                    objMembershipUser = Membership.GetUser(HiddenUserName.Value);
                    objMembershipUser.UnlockUser();
                    fillGrid("sort");
                    lblMainMsg.Style.Add("color", "Green");
                    lblMainMsg.Text = string.Format("User : {0} account is successfully unlocked!!!", HiddenUserName.Value.ToString());
                }
            }
            catch (Exception ex)
            { //throw ex;
            }
        }
开发者ID:shekar348,项目名称:1PointOne,代码行数:84,代码来源:UserSettings.aspx.cs

示例5: Unlock

 public bool Unlock(MembershipUser user)
 {
     return user.UnlockUser();
 }
开发者ID:EdsonF,项目名称:nextra,代码行数:4,代码来源:MembershipFacade.cs

示例6: IsResetUrlValid

        public bool IsResetUrlValid(string hash, out MembershipUser user)
        {
            user = null;
            var isValid = false;
            if (!string.IsNullOrEmpty(hash))
            {
                ResetPasswordModel link = _resetPasswordRespository.Find(hash);

                isValid = (link != null && link.ExpireDate > DateTime.Now);
                if (isValid)
                {
                    user = Membership.Provider.GetUser(link.UserName, false);

                    if (user == null)
                    {
                        string userName = Membership.GetUserNameByEmail(link.UserName);
                        user = Membership.Provider.GetUser(userName, false);
                    }

                    if (user != null && user.IsLockedOut)
                    {
                        user.UnlockUser();
                    }
                }
            }

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

示例7: gviewClients_RowCommand

        protected void gviewClients_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                HiddenUserName.Value = e.CommandArgument.ToString();
                if (e.CommandName == "Edit")
                {
                    UpdateClientModalPopupExtender.Show();
                    objMembershipUser = Membership.GetUser(HiddenUserName.Value);
                    txtUsername.Text = HiddenUserName.Value;
                    txtEmail.Text = objMembershipUser.Email.ToString();
                    chkStatus.Checked = objMembershipUser.IsApproved;
                    txtPassword.Text = objMembershipUser.GetPassword();
                    //fill user information from profile
                    objProfileBase = ProfileBase.Create(HiddenUserName.Value, true);
                    txtFirstname.Text = objProfileBase.GetPropertyValue("FName").ToString();
                    txtLastname.Text = objProfileBase.GetPropertyValue("LName").ToString();
                    txtMobilePhone.Text = objProfileBase.GetPropertyValue("MobilePhone").ToString();
                    txtHomePhone.Text = objProfileBase.GetPropertyValue("HomePhone").ToString();
                    txtPostalCode.Text = objProfileBase.GetPropertyValue("PostalCode").ToString();
                    txtCompanyName.Text = objProfileBase.GetPropertyValue("CompanyName").ToString();
                    txtState.Text = objProfileBase.GetPropertyValue("State").ToString();
                    txtCountry.Text = objProfileBase.GetPropertyValue("Country").ToString();
                    txtWorkPhone.Text = objProfileBase.GetPropertyValue("WorkPhone").ToString();
                    txtFax.Text = objProfileBase.GetPropertyValue("Fax").ToString();
                    txtAddress.Text = objProfileBase.GetPropertyValue("Address").ToString();
                    txtDBServerName.Text = objProfileBase.GetPropertyValue("DBServerName").ToString();
                    txtDBName.Text = objProfileBase.GetPropertyValue("DBName").ToString();
                    txtDBUserID.Text = objProfileBase.GetPropertyValue("DBUserID").ToString();
                    txtDBPassword.Text = objProfileBase.GetPropertyValue("DBPassword").ToString();
                    txtFromDomain.Text = objProfileBase.GetPropertyValue("FromDomain").ToString();
                    txtEVMTAName.Text = objProfileBase.GetPropertyValue("MtaName").ToString();
                    txtEFromName.Text = objProfileBase.GetPropertyValue("FromName").ToString();
                    txtEReplyEmail.Text = objProfileBase.GetPropertyValue("ReplyEmail").ToString();
                    if (objProfileBase.GetPropertyValue("AccType").ToString() != string.Empty)
                        ddlEAdminAccType.Text = objProfileBase.GetPropertyValue("AccType").ToString();
                    upEditClient.Update();
                }
                //swaraj on 2nd march 2010
                //to reset password
                if (e.CommandName == "Reset Password")
                {

                    MembershipProvider Mp = Membership.Providers["MPforResetPwd"];
                    MembershipUser Mu = Mp.GetUser(e.CommandArgument.ToString(), true);
                    string password = Mu.ResetPassword();
                    //message body
                    StringBuilder body = new StringBuilder();
                    body.Append("<HTML><BODY>");
                    body.Append("<table width=\"100%\"><tr><td align=\"left\" colspan=\"3\" style=\"height:4px; color:green;\"><h3></h3> <td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\"> Hi&nbsp;" + Mu.UserName.ToString() + ",</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">Welcome to 1Point</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">You can login in to your account at:</td></tr>");
                    body.Append("<tr><td colspan=\"3\"><a href=\"" + ConfigurationManager.AppSettings["LoginUrl"] + "\">Login</a></td></tr>");
                    body.Append("<tr><td colspan=\"3\"></td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("\n<tr><td >Your new Pasword : &nbsp;&nbsp;" + password + "</td></tr> <tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">If there's anything we can do to help, please get in touch.</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                    body.Append("<tr><td colspan=\"3\">Regards,</td></tr>");
                    body.Append("<tr><td colspan=\"3\">1Point team</td></tr>");
                    body.Append("<tr><td colspan=\"3\">" + ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').GetValue(0) + "</td></tr>");

                    MailMessage SendMessageToUser = new MailMessage();
                    SendMessageToUser.To.Add(Mu.Email.ToString());
                    SendMessageToUser.Body = body.ToString();
                    SendMessageToUser.Subject = "Your new password";

                    SendMessageToUser.IsBodyHtml = true;
                    //add cc of superadmin emails
                    ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').ToList().ForEach(delegate(string mail) { SendMessageToUser.CC.Add(mail); });
                    SmtpClient SmtpMail = new SmtpClient();
                    SmtpMail.Send(SendMessageToUser);
                    lblMsg.Style.Add("color", "Green");
                    lblMsg.Text = "Your new password has been emailed to  " + Mu.Email.ToString();
                }
                if (e.CommandName == "Unlock")
                {
                    objMembershipUser = Membership.GetUser(HiddenUserName.Value);
                    objMembershipUser.UnlockUser();
                    FillGrid(string.Empty);
                    lblMsg.Style.Add("color", "Green");
                    lblMsg.Text = string.Format("Client : {0} account is successfully unlocked!!!", HiddenUserName.Value.ToString());
                }
                if (e.CommandName.ToLower() == "delete")
                {
                    hdfield.Value = e.CommandArgument.ToString();
                    DeleteModalPopup.Show();
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:shekar348,项目名称:1PointOne,代码行数:94,代码来源:updateClient.aspx.cs

示例8: UnlockUserTest

 public void UnlockUserTest()
 {
     for (int i = 0; i <= Membership.MaxInvalidPasswordAttempts; i++)
     {
         Membership.ValidateUser(username, "wrong password");
     }
     User = Membership.GetUser(username);
     Assert.IsTrue(User.IsLockedOut);
     User.UnlockUser();
     Assert.IsFalse(User.IsLockedOut);
 }
开发者ID:joshrizzo,项目名称:MyLib,代码行数:11,代码来源:MembershipProviderTest.cs

示例9: 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

示例10: ModifyExistingUser

        private ModifyExistingUserResult ModifyExistingUser(BOMembershipUser membershipUser, MembershipUser membership)
        {
            BOUser user = membershipUser.User;

            if (!string.IsNullOrEmpty(membershipUser.Password))
            {
                if (membership.IsLockedOut)
                    membership.UnlockUser();
                BOUser.ChangePasswordResult result = user.ChangePassword(membershipUser.Password.Trim());
                if (result != BOUser.ChangePasswordResult.Success)
                {
                    switch (result)
                    {
                        case BOUser.ChangePasswordResult.CannotReusePassword:
                            return ModifyExistingUserResult.CannotReusePassword;
                        case BOUser.ChangePasswordResult.InvalidPassword:
                            return ModifyExistingUserResult.InvalidPassword;
                        default:
                            return ModifyExistingUserResult.Failed;
                    }
                }
            }
            if (membership.Email != membershipUser.Email)
            {
                membership.Email = membershipUser.Email;
                Membership.UpdateUser(membership);
            }
            return ModifyExistingUserResult.Success;
        }
开发者ID:TrevorVonSeggern,项目名称:Dota-Betting-ELO,代码行数:29,代码来源:UserService.cs


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