Using SqlMembershipProvider in desktop application
Posted on 2008-10-06
I'm creating a desktop application which will be used to automate some administrative tasks on a database which is mainly used as database behind a web page.
Web application is using aspnet user and role management, so all users, roles, passwords etc. are stored in our database in auto generated tables with prefix 'aspnet_'.
Now I have to create a way to authenticate aspnet users in my desktop application.
How can I do that?
I tried using System.Web.Security.SqlMembershipProvider.ValidateUser ("username","password"), but it throws 'Object reference not set to an instance of an object'.
I tried copying <providers> tag in many different ways from web application's web.config to my app.config but no matter what I do, I'm getting the same error.
As you probably might have figured, I have never used aspnet authentication in desktop or web application, so I have no idea how this works, or if it is even possible to make it work in the way I want.
If there's no way to make SqlMembershipProvider work in desktop application, is there a way to encrypt and compare user's password to a stored password in aspnet_Membership.Password field?
Basically all I need to do is find out if user's password is correct and get his userID.