1

Please can someone help me in the right direction to achieving a modern login, using information from a database?

I have a Microsoft SQL database that holds the username and password information.

I wish to take the user's credentials, authentication and then start a session for them.

I'm aware of how to do a login using PHP and best practices such as hashing and salting, re-creating the session id upon login, but the Internet is failing me on this one for ASP.NET. The results are linking me to old ways of doing things using ADO.

There's built in tried and tested Classes for doing authentication aren't there, but how do I make use of them with an SQL database?

4 Answers 4

1

The built in providers implement their database schema. If you have an existing database or want to use your own customized database schema, you'll have to roll your own membership provider, which is as easy as implementing an the MembershipProvider interface.

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

2 Comments

That sounds like what I need. So I can use whatever method that I want to authenticate? But then use ASP.net's Membership functions?
Yes, and it is my preferred way on almost all of my non-SO projects. The FormsAuthentication class is great at handling login cookie for you, so just implement the authentication to meet your schema requirements and let the parts that work do their thing. I should point out, you don't need to implement all the functions, just the ones you intend to use. You can identify the ones you need by starting with them all throwing NotImplementedException and implementing them until they stop happening. You generally only need 2 or 3 of the functions.
1

The standard way of doing this is well documented, take a look here:

http://msdn.microsoft.com/en-us/library/6e9y4s5t

Comments

0

Have a look at Introduction to Membership (MSDN) and the SqlMembershipProvider Class. This may help you. This solution is tied its own DB-schema though.

Comments

0

You can take a look at ShoelaceMVC. It uses the CodeFirstMembership project from codeplex to implement a custom membership provider for an ASP.NET MVC application. All the code's there and open to check out. Make sure you look at the example project under the ShoelaceMVC-Project folder as the others are project templates and nuget packages, and won't be a complete example for you.

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.