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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing Windows UserGroups access to buttons / methods

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
Having obtained the logged on user name and the usergroup(s) that they are included in (considering they may be included in more than one) how can we then allow / prevent said user to make use of the code / method behind a button.
Someone's mentioned making use of code directly above the method (i.e. button1_Click(..)) that checks the status / usergroup and then runs the code or not accordingly.
How do I go about making use of this concept.
Say I have five buttons, each accessible dependent on the user's inclusion in various combinations of user groups - how can I set up this as a simple example application ?
Any help would be greatly appreciated.
Thanks in advance
Steve
 
The solution to deal with that is to have a data base in which you store the user information like as user name, roles and profiles with the rights granted (read only, execute, write etc...).
Here you put rights to execute an application or not for a given user, to enable/disable a menu item depending on the user profile stored in the Profiles /Roles tables,
enable/disable/hide buttons depending on the user info, also query a recordset of data and display some records depending on the user right.
First of all , for a given application you retrieve the user/application info from the database and if the user is not authorized to run it (flag is in the database) then you notify it and close else before you make the window visible you enable/disable some menu items depending oh the flags set in the database for this user and this application/window. When the window is shown then the user access only the enabled menu items.
The same method you apply for the buttons.
The user, usergroups , roles, Profiles and Rights are all stored in the database.
Each user belongs to one or many usergroups.
Example:
userid =JohnA, usergroup = MANAGER, Window=Balancing application=CASHMACHINE, Window=Balancing ,Balance=false, Correct=false, Payments=false etc...
means:
When JohnA starts the CASHMACHINE application, in the " Balancing" window ,the "Balance", "Correct" and "Payments" menu items are disabled.

Separate all authorisation code in one .dll, link it with every application that you apply these checks.
Everything is resumed to call only a function GetAuthorization() which will retrieve all user/application info from the database, store it in the calling application and use this information before displaying menus/comtrols or later depending on the user actions (e.g. rights to see some recordset or update records).
-obislavu-

-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top