Using a custom user database (should I use a custom MembershipProvider)
-
Hello fellow developers! I'm currently working on a website in which users should be allowed to log in. We have an existing user database (SQL Server 2000), and I would like to use this database along with the ASP.NET login controls. Is this possible? I've been researching and found out that a possible solution would be to implement my own version of the MembershipProvider abstract class. Before I wander down that dirty dark road, I would like to know, if there is an easier way. I thought perhaps it would be possible to configure the SqlMembershipProvider to fit my needs. We are unable to change the design of the database since it is part of an existing system. Best regards Soeren
-
Hello fellow developers! I'm currently working on a website in which users should be allowed to log in. We have an existing user database (SQL Server 2000), and I would like to use this database along with the ASP.NET login controls. Is this possible? I've been researching and found out that a possible solution would be to implement my own version of the MembershipProvider abstract class. Before I wander down that dirty dark road, I would like to know, if there is an easier way. I thought perhaps it would be possible to configure the SqlMembershipProvider to fit my needs. We are unable to change the design of the database since it is part of an existing system. Best regards Soeren
If you're looking to use the existing database for login validation then all you need to do is handle the OnLogin event of the Login Control and authenticate against it. No need to implement a Membership Provider.
only two letters away from being an asset
-
If you're looking to use the existing database for login validation then all you need to do is handle the OnLogin event of the Login Control and authenticate against it. No need to implement a Membership Provider.
only two letters away from being an asset
Okay. Looks nice. I assume this is what you want me to do:
<asp:Login runat="server" ID="loginBox" OnLoggingIn="LogMeIn">
</asp:Login>And in the "LogMeIn" function I should implement my login validation. Can I be sure, that this will override whatever build in authenticate methods the login contol may have? The reason I'm asking is because the standard setup seems to work against some database in my App_Data folder, without any code at all. Best reagards Soeren
-
Okay. Looks nice. I assume this is what you want me to do:
<asp:Login runat="server" ID="loginBox" OnLoggingIn="LogMeIn">
</asp:Login>And in the "LogMeIn" function I should implement my login validation. Can I be sure, that this will override whatever build in authenticate methods the login contol may have? The reason I'm asking is because the standard setup seems to work against some database in my App_Data folder, without any code at all. Best reagards Soeren
Oh well stupid me just found out what I think you meant! ;) The solution must be to inherit the Login class, and implement your own version of
protected void OnAuthenticate(AuthenticateEventArgs e)
Inside this you do your user validation stuff and set the "e.Authenticated" property to true - if the user validates of course - otherwise false. It seems to do the trick for me.
If (I'm totally wrong)
please correct me! :-);Best regards Soeren
-
Oh well stupid me just found out what I think you meant! ;) The solution must be to inherit the Login class, and implement your own version of
protected void OnAuthenticate(AuthenticateEventArgs e)
Inside this you do your user validation stuff and set the "e.Authenticated" property to true - if the user validates of course - otherwise false. It seems to do the trick for me.
If (I'm totally wrong)
please correct me! :-);Best regards Soeren
Not at all what I meant. 1) Drop the login control on you page 2) Implement OnLoggingIn handler 3) Authenticate user in any way you choose 4) Call FormsAuthentication.RedirectFromLoginPage Simple as that, no need to create a derived class
only two letters away from being an asset