[英]Login in winforms app with users from a website database that uses hashes
I have a solution in Visual studio2012 with one website and one winform app.In the website I use the asp.net configuration for login and register.The authentication in the website is working perfect.It uses usernames and stores passwords(Hashes).I need to login in the winform app with the users of the website.I try this but it is not workingseems. 我在Visual Studio2012中有一个具有一个网站和一个winform应用程序的解决方案。在该网站中,我使用asp.net配置进行登录和注册。该网站中的身份验证工作正常,它使用用户名并存储密码(哈希)。需要与该网站的用户登录winform应用。我尝试这样做,但似乎无法正常工作。
SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Basketball;Integrated Security=True;User ID=userpol;Password=poluser");
SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From aspnet_Membership where UserId='" + textBoxUser.Text + "' and Password ='" + textBoxPass.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
GameChoose gc = new GameChoose();
gc.Show();
}
else
{
MessageBox.Show("please check your username and password");
}
Any Idea how to How to Use a Membership Provider of ASP.NET in WINFORM Application ?I want only authentication user,pass. 任何想法如何如何在WINFORM应用程序中使用ASP.NET的成员资格提供程序?我只希望通过身份验证的用户。
Finally I made it using a Web Service 最终,我使用Web服务实现了它
public bool Validate(string username, string password)
{
return Membership.ValidateUser(username, password);
}
and in login form: 并以登录形式:
bool result = basketballWcf.Validate(textBoxUser.Text, textBoxPass.Text);
if (result)
{
this.Hide();
GameChoose gc = new GameChoose();
gc.Show();
}
else
{
MessageBox.Show("check please USERNAME or PASSWORD");
textBoxPass.Text = "";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.