I’m making an ASP.Net MVC 3 application in VS 2010. I have a task to create a settings page which would make the columns from the tables in my database with specific permissions (read, read/write etc.).
It’s the first time I have a task of this kind and I have no idea on how to make this.
I tried going right click on the project in VS and then go to Settings. There was a link which says that my project didn’t have a settings page, so I clicked it to create one. There appeared a table with settings but there are just public/internal access modifiers. I can’t seem to find write/read.
Is this the right way of creating a settings page? Or is there another?
I’m sorry Andrew. I answered your question in quite a rush previously. So, I think my answer became quite unclear. I’m so sorry. I will try my best to answer this more clearly. My answer can be quite long and I hope you are patient enough to finish reading this. 🙂
Actually, your problem can be solved in very easy way. Believe me! You actually don’t need a Setting page for this.
I suppose you will have a
Userstable in your database, for storing user accounts for your system. Right! And again, I suppose thatUserstable will have at least these following fields.I only suppose your database has this kind of schema. Or else, there must be other ways to set the permissions for your users in the table.
Alright, create another table called
Permissionsin your database. ThatPermissionstable will handle the permission rights for your users in the aboveUserstable. Ok! Then, you have two tables. One is your originalUserstable and another isPermissionstable.Ok! Our new
Permissionstable will have at least following fields:booleandata type, orbitdata type.TrueorFalseforBooleanand0or1forbit. This is entirely depends on the type of DBMS you use. ]PermissionRead. ]Alright, now you have two tables. These Permission read and write fields are for holding the permission rights for your users.
If you have the exact db schema as I described above, then you will have the following kind of relationship like this:
Users table
UserID | UserName | PW
U-001 | Tim | timpassword
U-002 | Jim | jimpassword
Permissions table
ID | UserID | PermissionRead | PermissionWrite
1 | U-001 | True | False
2 | U-002 | True | True
So, you can see that, User Tim which is UserID U-001 has Read-only permission and User Jim who is U-002 has both read-write permissions.
So, you can check the condition of these fields when a particular user login to the system. If he or she has
PermissionReadvalueTrueandPermissionWritevaluefalse, then that user has read-only permission right. Or else, if both values are true then that user has read-write permission. Ok!I tried my best to explain this, and I really do hope you can understand my answer. I really do…!!!
My suggestion is that, you should try this method first. And, if you are alright with this, I can explain more how to set group level permissions from this method. Ok! ‘Cause my answer became quite long, and I fear you become bored reading this… 😉