• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

asp.net C# field based security

I am writting an ASP.Net application using c#. I want to have a field and session based security in the application.
For example:
1. A user can be authorized or denied to have an access to a form.
2. A user can be given read-only, full access or hidden access to a field on the form.
3. All the permission will be loaded at the run time from database.

Query: The query is what could be the database structure and business logic in terms of performance. If someone has done any project like this please provide example in c#.
0
salmanfazal
Asked:
salmanfazal
  • 6
  • 4
1 Solution
 
DeathraceCommented:
Its simple. What u need to do is before you enable or disable any control on the form ,, get the user type lets say if user type = user1 where the user is readonly...then on the form loap through the control and set their enabled property to false.

This is how i did in my project,it works if you consider performance write a javascript which does this job.A few changes to this javascript might do the work.
http://forums.asp.net/p/1075890/1581002.aspx#1581002
0
 
salmanfazalAuthor Commented:
there could be visible = hide possiblity also. In case of a control to hide, webform should adjust the control in terms of alignment. what could be the methodology in this?

0
 
mlmccCommented:
We did a similar thing in a VB project.

The method we used was to
Load the form (hidden)
Used code to check the relevant fields on the form and set them as appropriate (hidden, enabled, etc) based on the permissions for the user.
Show the form.

mlmcc
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
salmanfazalAuthor Commented:
I think this is not a proper way of doing as this will destroy the whole form layout.
0
 
mlmccCommented:
Not sure what you mean by that.

mlmcc
0
 
salmanfazalAuthor Commented:
Lets assume that we have 10 fields divided into two columns and 5 rows on the form desgined at design time. Now if you hide the third field of column 1 there will be a empty gap. similarly if you hide a field on 3rd and 4th row of 2nd column then think of the layout.

in the above scenario, you mean to say that form will adjust the layout automatically?
0
 
mlmccCommented:
No, you will have gaps.  If that is a problem then perhaps you need to have multiple forms that show the information required for each user.

mlmcc
0
 
salmanfazalAuthor Commented:
Anyother suggestions in terms of dynamically arrange the fields on the form?
0
 
mlmccCommented:
How are the fields arranged on the form?

Are they in a single line across?

Howmany fields and how many may get suppressed.

mlmcc
0
 
salmanfazalAuthor Commented:
well we can have multiple rows and multiple columns. I think this could be done in a way that load the form at runtime. Read the permission from table and design the form.
0
 
salmanfazalAuthor Commented:
Thnx
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now