473,396 Members | 2,029 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,396 software developers and data experts.

Give permission to the users

In my module I have different users sush as administrators, managers,users.
I have a menu items displaying the differerent links to diferent pages.
All menu Items should be displayed to the admin, some menu items should be hidden from user and some other menu items should be hidden from mangers,how should it be done?
Oct 4 '08 #1
5 1438
joedeene
583 512MB
either the .visible or .enabled property in most controls, forms, menus, etc ?

the .visible property will pretend like its not even there, its not visible, the .enabled it shows it, but basically, you cant click it, or use its actions...

joedeene
Oct 4 '08 #2
I am sorry that you did not understand my question, I need the menu Items to be displayed or not at runtime in accordance with the person who has logged into the page.
ie
If a person logs into the page the system has to check whether it he is admin or staff or a manager.and then has to make decision whether to enable all menu items or to hide some items if the person is not a admin
any help?
Oct 4 '08 #3
joedeene
583 512MB
I am sorry that you did not understand my question, I need the menu Items to be displayed or not at runtime in accordance with the person who has logged into the page.
ie
If a person logs into the page the system has to check whether it he is admin or staff or a manager.and then has to make decision whether to enable all menu items or to hide some items if the person is not a admin
any help?

use a boolean then ? like if an admin logged in...

declare your booleans at the beginning, and once logged in, set a static(shared) boolean to true depending on the user authenticated, lets say a manager...

Expand|Select|Wrap|Line Numbers
  1.  
  2.         bool adminauthenticated = false;
  3.         bool managerauthenticated = true;
  4.         bool userauthenticated = false;
  5. //then code to show the page after logging in, then a simple if statement such as...
  6.  
  7.  if (managerauthenticated == true) 
  8.             {
  9.                 //enable some...
  10.             }
  11.             else if (adminauthenticated == true)
  12.             {
  13.                 //make visible, or enable all controls
  14.  
  15.             }
  16.             else if (userauthenticated == true)
  17.             {
  18. //show the controls you want
  19.             }
is this something useful ?

joedeene
Oct 4 '08 #4
Mr Gray
47
You can check the user by:

Expand|Select|Wrap|Line Numbers
  1. IPrincipal user = Page.User;
  2.  
Then you can check that the user is in a specific group like so:

Expand|Select|Wrap|Line Numbers
  1. string strRoleToCheck = "Administrator"; // could be what ever group you need to give permission to.
  2. user.IsInRole(strRoleToCheck)
  3.  
Oct 4 '08 #5
tlhintoq
3,525 Expert 2GB
I am sorry that you did not understand my question, I need the menu Items to be displayed or not at runtime in accordance with the person who has logged into the page.
ie
If a person logs into the page the system has to check whether it he is admin or staff or a manager.and then has to make decision whether to enable all menu items or to hide some items if the person is not a admin
any help?
I think the part that isn't being said is that you have to manually turn each and every menu option on or off. There isn't an 'automatic' way of doing it.

1. The user logs in
2. That loads their permissions from someplace. Might be database, file, registry, whatever you decide.
3. As JoeDeene suggested, hold their permissions in a series of booleans. For example "bShowConfirmDialogs", "bAllowChangeUsers", "bAllowExitApp"
4. Once logged in set all the booleans from their permissions.
5. Go to a method that turns on features and menus according to the booleans.

I usually have a series of statements like this....
Expand|Select|Wrap|Line Numbers
  1. closeToolStripMenuItem.Visible = bAllowExitApp;
  2. edituserToolStripMenuItem.Visible = bAllowChangeUser;
Also, don't forget there is more than one way to do many things, like exit an application. Just because you take away the File|Exit choice there is also the big red 'X' button as well as [ALT]+[F4], and closing from the task bar. So you have to make sure you check the bAllowExitApp permission when the application is closing. If there is a way around something, some user will find it. You have to cover all the bases.
Oct 5 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Richard Muller | last post by:
Hi, I new to ASP. I have a problem with an ASP script opening a file for writing on my server. Here's how I got to this error: I downloaded a neat FileUpload ASP example from...
12
by: Vlad de Mille IV | last post by:
Well, as the subject says.... Briefly, when I try to run *any* wizard, I get a simple dialog, stating "Permission Denied", to which I can only click "OK". I suspect this is a windows (XP)...
2
by: Taishi | last post by:
New user of SQL Everything is on the same machine My error is close to the bottom After reading it today, I can see there is a problem with 2 dbases 'PUBS' and 'Master' There are also some...
2
by: scott | last post by:
Hi, I followed everything this article suggests: http://support.microsoft.com/default.aspx?scid=kb;EN-US;836734 Yet I still get the following message when stepping into a SP: "Cannot...
2
by: James | last post by:
Hi all, I am new to ASP.NET. I am currently working on a project with VB, .NET 1.1 on a Windows 2000 server. I have two files C:\Inetpub\wwwroot\test\test.aspx...
15
by: sflynn | last post by:
I've just created a new program in Visual Studio 2005, Visual Basic. I can publish, install, and run the program just fine as long as the user is a member of the "Domain Admins" group. My problem...
5
by: Kurda Yon | last post by:
I want to create a publicly accessible php page which will generate images (with the GD library) and store them in some directory. For this I have to change the permission of directory (it has to...
3
by: Charlotte | last post by:
Hello, info: I'me a rookie with IIS I have on a WinXP Pro the IIS installed, so I can test some pages before uploading to the hostserver online on the hostserver is a possibility (with the...
2
dlite922
by: dlite922 | last post by:
This is a totally n00b question but I'm saying good bye to Windows slowly and I've come across where I need to own a directory but I want to give write permission to Smarty (Apache user). Right now I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.