JiKra
JiKra

Reputation: 1790

Custom authentication against SQL Server database

I have a WPF application and a SQL Server database with a Users table. Every user has it's own row including hashed password and role in Users table.

I need to let them authenticate in my application and keep some kind of credentials, including role. Based on that role, they will see only what they should see.

Can you give me some clue how to accomplish it? What is the best way to keep those credentials and hide parts of my application based on user's role?

Thanks for any help, JiKra


Ok, I was thinking and how about to use a singleton? User authenticates, I grab his role from database, instantiate a singleton, set his credentials and use them in my app. Is that correct? It's the easiest way to do that? JiKra

Upvotes: 2

Views: 1610

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48230

The "functional model" as you call it can be based on the MembershipProvider/RoleProvider APIs. There's a tutorial video by Todd Miranda:

http://windowsclient.net/learn/video.aspx?v=293710

What the tutorial lacks is where you should store the information so that it's available for the other parts of the application. The answer is simple - since you have the stateful application, you can store the information in a shared (static) resource in a class.

Please also be aware of a potential security risk, I've added a comment under your question.

Upvotes: 1

Related Questions