views:

52

answers:

3

I'm writing a multiuser application (.NET - C#) in which each user's data is separated from the others and there is no data that's common between users. It's critical to ensure that no user has access to another user's data.

What are some approaches for implementing security at the database level and/or in the application architecture to to accomplish this? For example (and this is totally made up - I'm not suggesting it's a good or bad approach) including a userID column in all data tables might be an approach.

I'm developing the app in C# (asp.net) and SQL Server 2008. I'm looking for options that are are either native in the tools I'm using or general patterns.

+1  A: 

I believe associating data with a user via a user id is the most common approach.

Another approach is encryption. Each user could have some secret key, an actual digital key or maybe just a password, and all their data could be encrypted with their secret key so that other users wouldn't be able to access it. You would still need to associate data with user ids for querying etc.

TJB
Good point, and I think this encryption capability is native to SQL Server now.
Emilio
A: 

You could do this 1. Create a dbo.users table and have following columns, note this is not complete

table users
 -pid [uniqueidentifier]
 -userfname
 -userlname
 -useremail
 -userpwd




table userdata
  - datapid 
  - pid
  - [other columns to hoold data]

once your user authenticates against this table then you just use the ppid to return and enter and update any data related to that user

ltech
@ltech - What is the purpose of the userdata table in this example? Also, would you include the user pid in all data tables? For example, let's say it was a contact management application and there was a table for all contacts. You'd include the user pid in that table right?
Emilio
A: 

why not using any kind of access methods (who can access which file, and has the rights of read, write and delete) that fits your problem if it works with your problem (i have no idea)? For example:

  • Manadatory Access Control known as (MAC)
  • Discretionary Access Control (DAC)
  • Role Based Access Control (RBAC)
  • Rule Based Access Control (RBAC)

you can read and select one of them if it fits your problem.

berkay
Hi berkay this applies to file system access but not SQL database access.
Emilio
@Emilio,i want to just remind it maybe there is a way to adapt (i have never used it) so i posted to give an idea. thanks for the answer.
berkay