Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Roles and Rights. 1

Status
Not open for further replies.

gazal

Programmer
Apr 30, 2003
212
0
0
OM
hi guys

i want ur help in implementing my logic. I want to make a simple user rights program. my logic is to first Create Roles, Assign the Roles Rights to Add / Edit etc... and later on Assign the Roles to indvidual users as per theire positions.
Here are the Table Structures along with Sample Data. I am not able to figure out how would i store the information that which role has got what rights.... infact i have posted this question earlier also but didnt get a satisfying reply, so this time i m to the point....

Login_Details Table:
+++++++++++++++++++

L_Tran_No Login_ID Login_Name Password IsActive
=============================================================
1 admin Administrator admin 1
2 sam sam sam 1


Parent_Menu_Master Table:
+++++++++++++++++++++++++

P_Menu_Id P_Menu_Name IsActive CanAccess
=================================================================
1 Daily Transactions 1 0
2 Administration 0 0
3 Reports 1 0
4 Utilities 0 0


Child_Menu_Master Table:
++++++++++++++++++++++++

C_Menu_Id C_Menu_Name C_IsACtive C_CanAccess
=================================================================
1 Collection Sheet 1 0
1 Audit Transactions 1 0
2 Company Master 1 0
2 Login Details 1 0
2 MemberShip Plans 1 0




there would be max two ROLES i.e. Administrators and Operators. As the name suggests the Administrators will have all the menu options enabled where as the Operators will have few. Let me be more precise my application Startup Form has got Four Command Buttons called

Admin, Transactions, Reports & Utilities. each of these buttons have got an MDI Form with Menu's in it, So my Parent_Menu_Master contains the Four options specified above and the Child_Menu_Master contains sub menus.

hope this is more precise and clear

gazal
 
gazal,

First off, you need to modify your table structure a bit. Right now you have these three entities,[ul][li]Login_Details[/li][li]Parent_Menu_Master[/li][li]Child_Menu_Master[/li][/ul]What you need is this,[ul][li]Login_Details[/li][li]Menu_Master[/li][li]Role[/li][li]Login_Role[/li][li]Menu_Role[/li][/ul]The Login_Details table can remain the same, but here are the fields for the other tables,[ol][li]Menu_Master[ul][li]Menu_Id[/li][li]Parent_Menu_Id[/li][li]Menu_Name[/li][/ul][/li]
[li]Role[ul][li]Role_Id[/li][li]Role_Name[/li][/ul][/li]
[li]Login_Role[ul][li]L_Tran_No[/li][li]Role_Id[/li][/ul][/li]
[li]Menu_Role[ul][li]Menu_Id[/li][li]Role_Id[/li][/ul][/li][/ol]Now, let me explain. Use the Login_Role table to create an association between the Logins and Roles. Use the Menu_Role table to create an association between the Roles and Menus.

Now you can pass the L_Tran_No to a query and have it return the list of menus available to that user by joining Login_Details to Login_Role to Menu_Role to Menu_Master.

The other part is setting up the Menu_Master table. Notice the Parent_Menu_Id field. Use it to store the Menu_Id of the parent menu for the child menus. For the parent menus, set Parent_Menu_Id equal to the Menu_Id.

Here is your sample data in Menu_Master,
Code:
Menu_Id  Parent_Menu_Id  Menu_Name
==========================================
1        1               Daily Transactions
2        2               Administration
3        3               Reports
4        4               Utilities
5        1               Collection Sheet
6        1               Audit Transactions
7        2               Company Master
8        2               Login Details
9        2               MemberShip Plans

To get the list of parent menus, have your query return records where Menu_Id = Parent_Menu_Id. To get the list of child menus for a given parent menu, have your query return records where Parent_Menu_Id equals the Menu_Id of the desired parent.

Good luck, I hope this helps.

--Bill

BTW, it usually not a good idea to create a new thread with the same question, if you've posted a question and not gotten any responses. It's much better to make clarifications in the original thread. Duplicate threads tend to irritate regular users on the forum and it's considered bad etiquette. Just an FYI.

“I apologize for this long letter. I didn't have the time to make it any shorter” --Blaise Pascal
 
hi bill

thanks a lots this wat exactly i was looking for.

thanks buddy

gazal
 
How do i actually implement the application role in the VB Code?

Delton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top