473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

ARCHITECTURE : Enabling and disabling functionality in ASP.NET based on roles.

VSK
Hi all,

In our ASP.NET web application we have to enable or disable features in each
ASP.NET page based on role assigned to user.

Ex: if user who logs in is superisor then he can change phonenumber in
page1.aspx
if user who logs in is finaceofficial then he can just view the phone
number in page1.aspx

Thus Each page has elements whose functionality is enabled or disabled based
on roles.

Iam trying to do this checks in a Single class for all page and am not sure
whether it efficient.
My idea is to put code which checks the roles and enables and disabes server
controls in one class for easier maintenence.Not sure as to whether there is
any other alternative.

PS: am passing the entire Page object to the class :
objPageController.DeterminePageElements(this,"webf orm1");

Ex
a.aspx.cs
----------
private void Page_Load(object sender, System.EventArgs e)
{
PageController objPageController = new PageController();
objPageController.DeterminePageElements(this,"webf orm1");
}

PageController.cs
-----------------
public void DeterminePageElements(System.Web.UI.Page objPage,string
strPageName)
{
switch(strPageName){
case "webform1" :
//find the controls which are to be enabled or
//disabled from page collection.
//check for the role and credentials
//dummy code will be something like below
TextBox tb = objPage.FindControl("TextBox1");
if(security related checks)
{
tb1.Enabled = true;
}
else
{
}
case "" :
case "" :
....
}
}

Please let me know whether am doing anything wrong.

TIA for your patience
VSK


Nov 17 '05 #1
3 1929
"VSK" <vs*****@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...
Hi all,

In our ASP.NET web application we have to enable or disable features in each ASP.NET page based on role assigned to user.

Ex: if user who logs in is superisor then he can change phonenumber in
page1.aspx
if user who logs in is finaceofficial then he can just view the phone
number in page1.aspx

Thus Each page has elements whose functionality is enabled or disabled based on roles.

Iam trying to do this checks in a Single class for all page and am not sure whether it efficient.
My idea is to put code which checks the roles and enables and disabes server controls in one class for easier maintenence.Not sure as to whether there is any other alternative.

PS: am passing the entire Page object to the class :
objPageController.DeterminePageElements(this,"webf orm1");

Ex
a.aspx.cs
----------
private void Page_Load(object sender, System.EventArgs e)
{
PageController objPageController = new PageController();
objPageController.DeterminePageElements(this,"webf orm1");
}

PageController.cs
-----------------
public void DeterminePageElements(System.Web.UI.Page objPage,string
strPageName)
{
switch(strPageName){
case "webform1" :
//find the controls which are to be enabled or
//disabled from page collection.
//check for the role and credentials
//dummy code will be something like below
TextBox tb = objPage.FindControl("TextBox1");
if(security related checks)
{
tb1.Enabled = true;
}
else
{
}
case "" :
case "" :
....
}
}

Please let me know whether am doing anything wrong.


Why in the world would you want one class to be aware of all of your pages?

You can easily enable or disable a control by setting its Enabled property
based on IsInRole:

txtPhoneNumber.Enabled = Page.User.IsInRole("Supervisor")

--
John
Nov 17 '05 #2
VSK
this is the design in this company according to which when user logs in a
user object is created with uname,logintime, multiple roles(not single
role).

For each role we will get pagesection credentials.
Pagesectioncredentials table
----------------------------
pagesectioncredentailsid pageid sectionid roleid isenabled
1 1 1 1
0/1
where sectionid represents functionality in page.

So we have to get the roles and then pagesectioncredentails for each of them
and then enable or disable based on "isenabled" field.
There is no scope for changing DB design at this point of time....

i have worked with a user with single role in prev projects.this is new to
me.. :)

thanks for the suggestion

VSK

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
"VSK" <vs*****@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...
Hi all,

In our ASP.NET web application we have to enable or disable features in each
ASP.NET page based on role assigned to user.

Ex: if user who logs in is superisor then he can change phonenumber in
page1.aspx
if user who logs in is finaceofficial then he can just view the phone
number in page1.aspx

Thus Each page has elements whose functionality is enabled or disabled

based
on roles.

Iam trying to do this checks in a Single class for all page and am not

sure
whether it efficient.
My idea is to put code which checks the roles and enables and disabes

server
controls in one class for easier maintenence.Not sure as to whether

there is
any other alternative.

PS: am passing the entire Page object to the class :
objPageController.DeterminePageElements(this,"webf orm1");

Ex
a.aspx.cs
----------
private void Page_Load(object sender, System.EventArgs e)
{
PageController objPageController = new PageController();
objPageController.DeterminePageElements(this,"webf orm1");
}

PageController.cs
-----------------
public void DeterminePageElements(System.Web.UI.Page objPage,string
strPageName)
{
switch(strPageName){
case "webform1" :
//find the controls which are to be enabled or
//disabled from page collection.
//check for the role and credentials
//dummy code will be something like below
TextBox tb = objPage.FindControl("TextBox1");
if(security related checks)
{
tb1.Enabled = true;
}
else
{
}
case "" :
case "" :
....
}
}

Please let me know whether am doing anything wrong.
Why in the world would you want one class to be aware of all of your

pages?
You can easily enable or disable a control by setting its Enabled property
based on IsInRole:

txtPhoneNumber.Enabled = Page.User.IsInRole("Supervisor")

--
John

Nov 17 '05 #3
I said nothing about single roles. A user can be in multiple roles, and
IsInRole can be used to test for each one.

--
John

"VSK" <vs*****@hotmail.com> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
this is the design in this company according to which when user logs in a
user object is created with uname,logintime, multiple roles(not single
role).

For each role we will get pagesection credentials.
Pagesectioncredentials table
----------------------------
pagesectioncredentailsid pageid sectionid roleid isenabled
1 1 1 1
0/1
where sectionid represents functionality in page.

So we have to get the roles and then pagesectioncredentails for each of them and then enable or disable based on "isenabled" field.
There is no scope for changing DB design at this point of time....

i have worked with a user with single role in prev projects.this is new to
me.. :)

thanks for the suggestion

VSK

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
"VSK" <vs*****@hotmail.com> wrote in message
news:Ol*************@TK2MSFTNGP12.phx.gbl...
Hi all,

In our ASP.NET web application we have to enable or disable features in
each
ASP.NET page based on role assigned to user.

Ex: if user who logs in is superisor then he can change phonenumber
in page1.aspx
if user who logs in is finaceofficial then he can just view the phone number in page1.aspx

Thus Each page has elements whose functionality is enabled or disabled

based
on roles.

Iam trying to do this checks in a Single class for all page and am not

sure
whether it efficient.
My idea is to put code which checks the roles and enables and disabes

server
controls in one class for easier maintenence.Not sure as to whether

there
is
any other alternative.

PS: am passing the entire Page object to the class :
objPageController.DeterminePageElements(this,"webf orm1");

Ex
a.aspx.cs
----------
private void Page_Load(object sender, System.EventArgs e)
{
PageController objPageController = new PageController();
objPageController.DeterminePageElements(this,"webf orm1");
}

PageController.cs
-----------------
public void DeterminePageElements(System.Web.UI.Page objPage,string
strPageName)
{
switch(strPageName){
case "webform1" :
//find the controls which are to be enabled or
//disabled from page collection.
//check for the role and credentials
//dummy code will be something like below
TextBox tb = objPage.FindControl("TextBox1");
if(security related checks)
{
tb1.Enabled = true;
}
else
{
}
case "" :
case "" :
....
}
}

Please let me know whether am doing anything wrong.


Why in the world would you want one class to be aware of all of your

pages?

You can easily enable or disable a control by setting its Enabled

property based on IsInRole:

txtPhoneNumber.Enabled = Page.User.IsInRole("Supervisor")

--
John


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rob Cowie | last post by:
Hi, This is my first post so go easy! I have been asked (as part of an MSc project) to create a server based planner for a research group at my uni. It will have a web interface to interact...
3
by: Michael Crawford | last post by:
Hi, Where would one start for this type of application: I want to create an vb.net container application that has the gives the end user the ability to install and uninstall plugins or add-in...
6
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that...
2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
0
by: VSK | last post by:
Hi all, In our ASP.NET web application we have to enable or disable features in each ASP.NET page based on role assigned to user. Ex: if user who logs in is superisor then he can change...
0
by: Jason Nadrowski | last post by:
VSK: Google Groups was having trouble "retrieving" (Unable to retrieve message urJo6GRmDHA.2488@TK2MSFTNGP12.phx.gbl) your message so I copied and pasted it below. Here are my thoughts: 1. I...
8
by: getdotnet | last post by:
We are designing a site with ASP.net 2.0. The question is regarding the options avialble in asp.net 2.0 and the best one to use Scenario All the pages have a top menu bar and header. (We plan to...
4
by: Raj | last post by:
Hi, I have set of exposed web method (C#, framework). Now set of retailer uses these methods and they are identified by their retailer ids. Question is, Is there any way to disable a few...
5
by: Slawomir | last post by:
I'm a new in ASP.NET Word. Just finishing writing my first web application (CMS). It should be available anonymously for all users, but some part (admin) should be available only for some...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.