简体   繁体   English

与使用哈希的网站数据库中的用户一起登录Winforms应用

[英]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.

相关问题 是否可以从Winforms应用程序登录到使用Spring Security的网站? - Is it possible to login from a winforms application to a website which uses spring security? 从WinForms登录到网站 - Login to website from WinForms 从应用程序登录网站 - Login to website from app 从 winforms 应用程序更新远程 web 数据库的最佳方法 - Best way to update remote web database from winforms app 以编程方式登录到使用IIS身份验证的网站 - Programatiically login to a website that uses IIS authentication C#-SQL数据库中的多个用户用于登录表单 - C# - Multiple Users from SQL Database for Login Form 为什么使用“新的NetworkCredential(用户名,密码)”不适用于我的网站的基本身份验证(来自WinForms C#应用程序)? - why is use of “new NetworkCredential(username, password)” not working for Basic Authentication to my website (from a WinForms C# app)? Winforms 从数据库中检索数据 - Winforms retrieving data from database 从Windows应用程序管理asp.net网站(创建新用户,将用户分配给角色等) - Administer asp.net website (create new users, assign users to roles, etc.) from a windows app 从winforms c#中的网站提取数据 - Extract data from a website in winforms c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM