Permission Control in c# and Windows Form

Asked

Viewed 1,129 times

0

I would like to create in C# with Windows Forms ( basically equal Windows folder permission), access levels for users, but not as level 1, 2 and 3, but for example:

  • User A can only view a customer registration;
  • User B can delete and delete;
  • User C can view only some fields of customer registration.

What would be the best way to do that?

Thank you for your attention

  • Hi buddy, good night, recommend reading https://www.codeproject.com/kb/miscctrl/application_login.aspx https://www.codeproject.com/kb/cs/securebaseform.aspx

  • Very complex what you want for a simple question...

2 answers

1

1 - A table in the database with bool fields to save the permission (a field for each item you want to change the permission)
2 - An object on your system to receive the database permission data;

3- On system startup when logging in you must scan the components by setting in the.enable component or comment.Visible the value of the corresponding permission.

1


You must build your application in the format "Rules-based" (role-based in English).

To do this, you can cause your Forms to inherit some specific access control behaviors.

Here you find a detailed tutorial on how to do this (in English).

With everything, this tutorial does not reach the field level (form only). This part you will need to implement "at hand" through the property Visible of the components.


Another way to implement is to do the access control before opening the form itself. Normally a database-based menu is used and this data can be set whether the menu option will be displayed or not.

But still, field-level permissions should be implemented manually.


Setar the property Visibile for false may lead to layout problems if you are not using specific layout classes (containers) in your form.

If not already using, I advise reading Flowlayoutpanel and Tablelayoutpanel

Browser other questions tagged

You are not signed in. Login or sign up in order to post.