Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a windows application in C#. An application may have multiple Users with some Roles assigned to them and multiple forms. What we want is to restrict a logged in user according to his role.

i.e for e.g. Admin is free to allowed to view all form there is all button Click in frmhome with the application, while some other users operator login may not be allowed to view some forms.eg.form1,form2 not view operator, not click button1 ,button2 . (my all form name is frmhome, form1,form2,form3,form4,form5 & frmhome form there are multiple buttons,
eg button1(form1),button2(form2),button3(form3),button4(form4),button5 (form5)if i click the button1 then open form1 . if role assign to view form1 to user.
in Mysql database all field username,password,form1sel,form2Sel.

if I register usernm :admin,password:admin,form1sel:yes.form2sel:yes save then open form1,form2 and I register usernm :operator,password:operator,form1sel:yes.form2sel:no save then open only form1 button onclick , not view/open form2 on button click

What I have tried:

I have try some code, when I login as operator then form1 not open on button click as I expect result.but when I login another user i.e admin then not open form1 I want click on form1 button then open form1.
Posted
Updated 9-May-21 11:04am
v2
Comments
Richard Deeming 8-Apr-21 5:51am    
There's a secret error somewhere in your secret code. You need to fix that.

Seriously, nobody can help you fix code that we cannot see.

NB: Based on your description, it sounds like you're storing passwords in plain text. Don't do that!
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]

1 solution

Make sure your logic surrounding the roles and how they are defined/stored/retrieved from the database is correct. You need to account for a role having enough granularity to be able to assign different roles and get the right list of forms they can use.

This can be tricky since you will eventually want to either expand the forms and/or revise the roles.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900