我的密码可以为密码做些什么? [英] What can be done for the password in my password?
本文介绍了我的密码可以为密码做些什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void btn_Giris_Click(object sender,EventArgs e)
{
try
{
USER usr = DB.USERs.First(s => ; s.USERNAME == txtUserName.Text&& s.PASSWORD == txtPassword.Text);
if(usr.ISACTIVE == true)
{
usr.ISONLINE = true;
DB.SubmitChanges();
Classes.ClsUser.UserName = usr.USERNAME;
Classes.ClsUser.UserID = usr.USERID;
this.Close();
}
else
{
MessageBox.Show(Aktif Degilsin,ADMIN,MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch(例外)
{
MessageBox.Show(kullanici adi veya parola hatasi);
}
}
我尝试过:
private void Parola_Animsa()
{
if(!Directory.Exists(Application.StartupPath +\\Pasword))
{
Directory.CreateDirectory(Application.StartupPath +\\Pasword);
}
string possibleFileName =(Application.StartupPath +\\Pasword\\+ Classes.ClsUser.UserName +#Public+。EdL);
if(File.Exists(possibleFileName))
{
string content = File.ReadAllText(possibleFileName);
txtPassword.Text = content;
}
}
private void checkBox1_CheckedChanged(object sender,EventArgs e)
{
Parola_Animsa();
}
解决方案
在数据库上存储密码不是一个好主意...
请参阅以下文章:
The Art&存储密码科学 [ ^ ]
密码存储:怎么做。 [ ^ ]
对于自动登录有特定的窗口选项,例如使用Windows身份验证 - 使用Windows身份验证(C#)对用户进行身份验证Microsoft Docs [ ^ ] - 然后启用自动登录 - 自动登录 - Windows Sysinternals | Microsoft Docs [ ^ ]
private void btn_Giris_Click(object sender, EventArgs e) { try { USER usr = DB.USERs.First(s => s.USERNAME == txtUserName.Text && s.PASSWORD == txtPassword.Text); if (usr.ISACTIVE == true) { usr.ISONLINE = true; DB.SubmitChanges(); Classes.ClsUser.UserName = usr.USERNAME; Classes.ClsUser.UserID = usr.USERID; this.Close(); } else { MessageBox.Show("Aktif Degilsin", "ADMIN", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("kullanici adi veya parola hatasi"); } } What I have tried: private void Parola_Animsa() { if (!Directory.Exists(Application.StartupPath + "\\Pasword")) { Directory.CreateDirectory(Application.StartupPath + "\\Pasword"); } string possibleFileName = (Application.StartupPath + "\\Pasword\\" + Classes.ClsUser.UserName + "#Public" + ".EdL"); if (File.Exists(possibleFileName)) { string content = File.ReadAllText(possibleFileName); txtPassword.Text = content; } } private void checkBox1_CheckedChanged(object sender, EventArgs e) { Parola_Animsa(); }
解决方案
Storing the password on a database is not a good idea...
See these articles:
The Art & Science of Storing Passwords[^]
Password Storage: How to do it.[^]
For "auto logon" There are specific windows options e.g. use Windows Authentication - Authenticating Users with Windows Authentication (C#) | Microsoft Docs[^] - and then enabling Autologon - Autologon - Windows Sysinternals | Microsoft Docs[^]
这篇关于我的密码可以为密码做些什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文