本文整理汇总了C#中System.Web.Security.MembershipUser.GetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipUser.GetPassword方法的具体用法?C# MembershipUser.GetPassword怎么用?C# MembershipUser.GetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Security.MembershipUser
的用法示例。
在下文中一共展示了MembershipUser.GetPassword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: UpdateUser
public void UpdateUser(MembershipUser user)
{
using (var context = new Security())
{
var usrToUpdate = context.Users.FirstOrDefault(f => f.Id == (int)user.ProviderUserKey);
usrToUpdate.Name = user.UserName;
usrToUpdate.Password = user.GetPassword();
usrToUpdate.LastLogin = user.LastLoginDate;
context.SaveChanges();
}
}
示例3: GeraBatAT
protected string GeraBatAT(bool sohUpdArqUser)
{
try
{
//Pega o usuário logado...
currentUser = Membership.GetUser();
//Pega a chave de Criptografia...
var Section = ConfigurationManager.GetSection("system.web/machineKey");
string aux = ((System.Web.Configuration.MachineKeySection)(Section)).ValidationKey.ToString();
bytes = ASCIIEncoding.ASCII.GetBytes(aux.Substring(0, 8));
string pathCMD = ConfigurationManager.AppSettings["SrvFolderSTasks"] + "\\";
string nomeCMD = "";
//MPS - 21/OUT---------------------------------------------
//Testa se existe parametros nos cmds...
if (lstATcmds.SelectedValue.ToString().IndexOf("[p1]") > 0)
{
string findParam = "";
string findParamConv = "";
string[] stringSeparators = new string[] { "[", "]" };
string[] vetParam = lstATcmds.SelectedValue.ToString().Split(stringSeparators, StringSplitOptions.None);
string[] vetParamConc = txtParams.Text.Split(stringSeparators, StringSplitOptions.None);
if (vetParam.Length == vetParamConc.Length)
{
foreach (string s in vetParam)
{
if (s.IndexOf(">>") == -1)
{
if (s.ToUpper().IndexOf("P") >= 0)
{ findParam = findParam + "[" + s + "] "; }
}
}
foreach (string s in vetParamConc)
{
if ((s != " ") && (s != ""))
{ findParamConv = findParamConv + s + " "; }
}
}
else
{ return "Erro"; }
nomeCMD = lstATcmds.SelectedValue.ToString().Replace(findParam, findParamConv);
}
else
{ nomeCMD = lstATcmds.SelectedValue.ToString(); }
//
//MPS - 21/OUT---------------------------------------------
string param = currentUser.UserName.Replace("\\", "_");
param += " ";
param += currentUser.GetPassword();
string cryptedparam = ""; //DS_AuditXML.Util_list.Encrypt(param, bytes);
//Grava param criptografado em arquivo...
string batCMD = pathCMD + "AT_" + currentUser.UserName.Replace("\\", "_") + "_" + txtHoraIni.Text + DateTime.Now.Second + ".bat";
string arqParam = pathCMD + "AT_" + currentUser.UserName.Replace("\\", "_") + ".txt";
//Cria/Atualiza o Arquivo de usuario para utilizar no app BATCH...
using (StreamWriter writer = new StreamWriter(arqParam, false))
{ writer.WriteLine(cryptedparam); }
if (!sohUpdArqUser)
{
//Cria um Arquivo BAt na pasta das ATs para executar via AT...
using (StreamWriter writer = new StreamWriter(batCMD, false))
{
writer.WriteLine("cd " + pathCMD.Replace("Tasks",""));
writer.WriteLine(nomeCMD);
}
return batCMD;
}
else
{
return arqParam;
}
}
catch (Exception ex)
{
return "Ocorreu um erro: " + ex.Message;
}
}
示例4: SendUserPasswordReminderNotification
/// <summary>
/// Sends the user password reminder.
/// </summary>
/// <param name="user"></param>
/// <param name="passwordAnswer"></param>
/// <returns></returns>
public static void SendUserPasswordReminderNotification(MembershipUser user, string passwordAnswer)
{
if (user == null) throw new ArgumentNullException("user");
//TODO: Move this to xslt notification
//load template and replace the tokens
var template = NotificationManager.Instance.LoadNotificationTemplate("PasswordReminder");
var subject = NotificationManager.Instance.LoadNotificationTemplate("PasswordReminderSubject");
var displayname = GetUserDisplayName(user.UserName);
var context = new NotificationContext
{
BodyText = String.Format(template, HostSettingManager.Get(HostSettingNames.ApplicationTitle),user.GetPassword()),
EmailFormatType = HostSettingManager.Get(HostSettingNames.SMTPEMailFormat, EmailFormatType.Text),
Subject = subject,
UserDisplayName = displayname,
Username = user.UserName
};
NotificationManager.Instance.SendNotification(context);
}
示例5: 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\"> </td></tr>");
body.Append("<tr><td colspan=\"3\"> Hi " + Mu.UserName.ToString() + ",</td></tr><tr><td colspan=\"3\"> </td></tr>");
body.Append("<tr><td colspan=\"3\">Welcome to 1Point</td></tr><tr><td colspan=\"3\"> </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\"> </td></tr>");
body.Append("\n<tr><td >Your new Pasword : " + password + "</td></tr> <tr><td colspan=\"3\"> </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\"> </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;
}
}
示例6: btnGeraClasse_Click
protected void btnGeraClasse_Click(object sender, EventArgs e)
{
//Pega o usuário logado...
currentUser = Membership.GetUser();
DataTable dt1;
//Testa a conexão com o Servidor Selecionado...
//Se não existir informa o usuario...
if (lstHost.SelectedItem == null)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Não foi selecionado o Servidor, por gentileza, selecione e tente novamente! </span>";
return;
}
if (lstTipoClasse.SelectedItem == null)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Não foi selecionado a Classe, por gentileza, selecione e tente novamente! </span>";
return;
}
//MPS 27/10/2014
bool connOK = false;
if (lstHost.SelectedItem.ToString().IndexOf(" [") > 0)
connOK = MPSfwk.WMI.testeConnWMI(lstHost.SelectedItem.ToString().Substring(0, lstHost.SelectedItem.ToString().IndexOf(" [")), currentUser.UserName, currentUser.GetPassword());
else
connOK = MPSfwk.WMI.testeConnWMI(lstHost.SelectedItem.ToString(), currentUser.UserName, currentUser.GetPassword());
if (!connOK)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>Não foi possivel se conectar ao Servidor selecionado! Talvez o IP/Host selecionado não foi encontrado, ou usuário sem privilégio. </span>";
return;
}
string classe = lstTipoClasse.SelectedItem.ToString();
string classe_SEL = lstTipoClasse.SelectedValue.ToString();
//MPS 27/10/2014
string server= "";
if (lstHost.SelectedItem.ToString().IndexOf(" [") > 0)
server = lstHost.SelectedItem.ToString().Substring(0, lstHost.SelectedItem.ToString().IndexOf(" ["));
else
server = lstHost.SelectedItem.ToString();
try
{
//Chama a função para o Gerenciamento WMI remoto/local
// se ocorre erro, tenta a conexão local...
if (classe_SEL == "Win32_GroupUser")
{
dt1 = MPSfwk.WMI.GroupMembers( server,
currentUser.UserName,
currentUser.GetPassword());
}
else
{
dt1 = MPSfwk.WMI.dtlistaClasse( classe,
classe_SEL,
server,
currentUser.UserName,
currentUser.GetPassword());
}
GridView2.DataSource = dt1;
GridView2.DataBind();
string dthr = DateTime.Now.ToString("yyyyMMddHHmmss");
string arq = ConfigurationManager.AppSettings["XMLData"] + currentUser.UserName.Replace("\\", "_") + "\\" + classe + "_" + server + "_" + dthr + ".xml";
dt1.WriteXml(arq);
//Grava o XML no banco de Dados...
XmlDocument xmlSave = new XmlDocument();
xmlSave.Load(arq);
SqlServer.AuditXML.Gravar(classe, server, dthr, xmlSave);
//Grava e disponibiliza o XML...
dtSel2.Visible = true;
dtSel2.Text = dthr;
String strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace("Audits.aspx", "");
string str_lnk = currentUser.UserName.Replace("\\", "_") + "\\" + classe + "_" + server + "_" + dthr + ".xml";
string str_href = strUrl + "Xml_Data\\" + str_lnk;
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" +
"Geração efetuada com sucesso em: <a href=" + str_href.Replace(" ", "%20") + ">" + str_lnk +
"</a> </span>";
}
catch (UnauthorizedAccessException was)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Ocorreu um erro - Acesso não autorizado: " + was.Message + " </span>";
}
catch (ManagementException ex)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Ocorreu um erro de gerenciamento: " + ex.Message + " </span>";
}
catch (Exception eg)
{
divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Ocorreu um erro: " + eg.Message + " </span>";
}
//Limpa e atualiza a ultima Data Gerada...
drpGeracoes.Items.Clear();
// Atualiza a lista de datas de geracao...
DS_AuditXML.Util_list.ListaDTsGeracao(ordBY, aud, lstHost, lstTipoClasse, drpGeracoes, drpGeracoes);
//.........这里部分代码省略.........
示例7: SendUserPasswordReminderNotification
/// <summary>
/// Sends the user password reminder.
/// </summary>
/// <param name="username">The username.</param>
/// <returns></returns>
public static void SendUserPasswordReminderNotification(MembershipUser user, string passwordAnswer)
{
if (user == null)
throw new ArgumentNullException("user");
//load notification plugins
NotificationManager nm = new NotificationManager();
nm.LoadNotificationTypes();
//load template and replace the tokens
string template = nm.LoadNotificationTemplate("PasswordReminder");
string subject = nm.LoadNotificationTemplate("PasswordReminderSubject");
string displayname = ITUser.GetUserDisplayName(user.UserName);
nm.SendNotification(user.UserName, subject, String.Format(template, HostSetting.GetHostSetting("ApplicationTitle"), user.GetPassword(passwordAnswer)));
}
示例8: UpdateUser
public override void UpdateUser(MembershipUser user)
{
Models.User u = Models.User.GetByEmail(user.Email);
u.Password = user.GetPassword();
u.LastAccess = user.LastActivityDate;
u.IsActive = user.IsApproved;
u.CreatedAt = user.CreationDate;
Models.User.SaveUser(u);
}