3

I have a small db, nothing fancy just 5 tables. I would like to use forms authentication but it creates its own db to do its stuff. I don't need anything fancy, and I certainly don't need the added infrastructure, but I'd like the security forms authentication provides. I have a person table, with a login and password field. how can I make it so forms uses these fields and returns my users id? is this even possible with forms? if not, how can I make it so forms creates it's infrastructure on my db so I can merge my tables with the ones forms needs to work?

I know this is probably quite simple but I haven't found anything on the net after hours of research.

3 Answers 3

3

Actually, I'm not sure why the answers here imply that Forms Authentication somehow must be used with ASP.Net Membership or the ASP.Net infrastructure for it (providers, etc).

You can certainly use Forms Authentication without any of them and use your existing user tables (that have nothing to do with ASP.Net Membership or any provider for that matter).

This is taken from MSDN:

<script runat="server">
  void Logon_Click(object sender, EventArgs e)
  {
    if ((UserEmail.Text == "[email protected]") && 
        (UserPass.Text == "37Yj*99Ps"))
      {
          FormsAuthentication.RedirectFromLoginPage 
             (UserEmail.Text, Persist.Checked);
      }
    else
      {
          Msg.Text = "Invalid credentials. Please try again.";
      }
  }
</script>

While the above is (over) simplified, you can see where you can replace the code with db lookup queries....

Update: modified link (corrected it to point to MSDN)

Sign up to request clarification or add additional context in comments.

2 Comments

hmmmm that looks interesting. certainly more attractive than writing a whole provider. I'll take a look at it. thanks!
No problem - while writing a provider and/or overriding methods in existing providers is certainly possible, just wanted to clarify that Forms Authentication is not dependent on them. It can be "bolted on" to your (pre)existing user/pwd scheme/database tables, etc. - using Forms Authentication doesn't mean you have to "replace" your existing infrastructure - you can if you want to, but its not necessary...
1

If you want to use your own tables then you're going to have to implement your own MembershipProvider. This allows you to use your own tables and stored procedures, but still hook into the forms auth structure.

Comments

-1

The tool you're looking for is called aspnet_regsql: http://msdn.microsoft.com/en-us/library/ms229862.aspx

And here's a more comprehensive answer than mine: https://stackoverflow.com/a/4030700/44372

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.