I am creating a web application in asp.net c#.
The project is for assigning tasks to different employees in the system. The project requires that, there are three types of employees, and the privileges corresponding to them are basic, superviser and manager.
The "basic" privilege only has the option to view his/her profile. The "superviser" can create jobs, and when "manager" approves the job, it would become available, and the "superviser" can assign the job to an employee.
As said above, aach of the privileges have a set of avaiable "Actions". My requirement is the following:-
After an employee is created by the admin, the employee need to be given the privileges. The admin can select the privileges (say for example, for basic employee-->view profile, view the work assigned; for superviser--> view profile, create jobs, assign employee to jobs; for manager--> view profile, create job, approve job, assign work to employee; for admin--> all privileges). The admin should be able to "check" the checkboxes associated with each privilegs, and based on these selections, privileges should be assigned to each employee.
How do we do this.
NB:- I dont want to use the "Roles" feature in ASP.NET C#. This is because, only privileges created by the programmer can be used. I want the admin to create roles, by giving a role name, and selecting various privileges.
I have had a look at the features of default asp.net roles and privileges, but my requirement is on the other side of the court.
The project has different users, and I don't want to categorize them as either "basic emp", "hr", "pm", etc. Instead I would prefer to have a seto of checkboxes, and select the required privileges by using the check boxes.
An employee who has been given the privileges by selection of checkboxes can access the corresponding pages.
For example:
I have a set of checkboxes having associated data as:-
-view profile
-edit profile
-create project
-edit project
-upload resume
If I select the checkboxes corresponding to them, the corresponding web pages will be accessible to them.
How is this possible?
Iftikar HussainPosted Aug 5, 2013, 11:44 PM
For different user you can show different menu item, for that you need to create two table
WebMenu
----------
MenuId,
MenuName,
NavigateUrl,
ParentId (it will be menu id only for submenu)
WebMenuUserLink
-----------------
MenuId
UserId
Please refer the below link for creating menu using database
http://www.codeproject.com/Tips/354696/Dynamically-populating-menu-items-from-the-databas
If you want to display different content depend on different user, then
if it is just a plain text content, then create two table (same as like above)
if it is contain control, text etc then create different type of usercontrol
Regards,
Iftikar
Roshan GeorgePosted Aug 5, 2013, 11:00 PM
What is the use of "userid" in the first table?
I could find a reason for adding userid to that table.
Another question that came to my mind is :-
Since different users will have different pages that will be available, the menu items should also have to change. How do we show different menus to different users in this case?
Also, suppose that we require same menu name/page name with different content for different users. How will we show this?
Iftikar HussainPosted Jul 27, 2013, 10:23 AM
Create a master table to maintain all these page name and create a link table for storing linking for each user to these page.
TablePages
-------------
PageId int (PK),
PageName varchar(20),
UserId varchar(30) (FK)
TableUserLinkPage
------------------
UserId varchar(30) (PK)
PageId int (PK)
While creating a new user, for each user store respective checked web page value in TableUserLinkPage
for e.g.
User1 has been created with view and edit profile option checked
the table will be contain value like this
TestUser->1 (ViewProfile PageId)
TestUser->2 (EditProfile PageId)
when User1 login to your application, from each page check weather he has got access to that page or not by passing PageId
Regards,
Iftikar