473,471 Members | 4,629 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Form controls security

Hi everyone!
I am developing app, which should be used by users, which are members of
different groups.
These users and groups are stored in my SQL database and are custom for my
application, they are not Windows users.
Every user can be member of many groups.
What I need is a some kind of baseline, how to implement security in my app,
based on these users and groups.
By security I mean enabling and disabling different functionality of my app,
mosltly disabling controls.
Should I use some kind of ACL, or on every Form load event I should enable
or disable controls, based on the group membership of user.
Because I am a newbie, some source code will be helpfull.

TIA
Nov 21 '05 #1
4 1532
Hi Nikolay

This is how i implemented security on my company
managment system i currently develloping. I
enable/disable buttons , Main menus and Context menus
based the user at form load.

As you know there's a collections of controls in each
form, buttons and menus are controls BUT context menus
are components and are not listed in the controls
collection. So i had to use system.reflection to do it.
Below is the procedure i use to browse buttons
Imports System.Reflection

Public Sub BrowseButtons(ByVal f As Form)

Dim MyForm As Type = f.GetType()

Dim Fields As FieldInfo() = MyForm.GetFields
(BindingFlags.Instance Or BindingFlags.NonPublic)

For Each Field As FieldInfo In Fields
If Field.FieldType.Name = "Button" Then
Dim obj As Button = DirectCast(Field.GetValue(f),
Button)

WorkerID = 80 '' i am the admin and have access
to everything
NomeForm = f.Name
Button_ = obj
ControlName = obj.Name
SaveButton() '' saves the button the table
End If

Next

End Sub
The BrowseContextMenus and BrowseMainMenus are similar.
I have a table with a entry for each buttons/menus with
the worker id. By default i have acess to everything and
the other no acess, so when i browse the controls i save
a entry in the table with my worker id, this way if i had
an new button or contextmenu item it will be saved next
time i run the application.

When the form loads i do :
BrowseButtons(me)
BrowseContextMenus(me)
BrowseMainMenus(me)
EnableButtons(me)
EnableContextMenus(me)
EnableMainMenus(me)

And below is a line of the sql table i use

80 FormEnc System.Windows.Forms.MenuItem,
Items.Count: 0, Text: Tradução das Preconizações
System.Windows.Forms.ContextMenu, Items.Count: 23
3942

Kind Regards
Jorge
-----Original Message-----
Hi everyone!
I am developing app, which should be used by users, which are members ofdifferent groups.
These users and groups are stored in my SQL database and are custom for myapplication, they are not Windows users.
Every user can be member of many groups.
What I need is a some kind of baseline, how to implement security in my app,based on these users and groups.
By security I mean enabling and disabling different functionality of my app,mosltly disabling controls.
Should I use some kind of ACL, or on every Form load event I should enableor disable controls, based on the group membership of user.Because I am a newbie, some source code will be helpfull.

TIA
.

Nov 21 '05 #2
Hi,

http://msdn.microsoft.com/library/de...nroletopic.asp

Ken
-----------------------------
"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
Hi everyone!
I am developing app, which should be used by users, which are members of
different groups.
These users and groups are stored in my SQL database and are custom for my
application, they are not Windows users.
Every user can be member of many groups.
What I need is a some kind of baseline, how to implement security in my app,
based on these users and groups.
By security I mean enabling and disabling different functionality of my app,
mosltly disabling controls.
Should I use some kind of ACL, or on every Form load event I should enable
or disable controls, based on the group membership of user.
Because I am a newbie, some source code will be helpfull.

TIA

Nov 21 '05 #3
Ken, I don't need the Windows Users and Groups. I have my own users and
groups in DB.

My actual question is how to define some kind of ACL and use them on
controls.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uk***************@TK2MSFTNGP09.phx.gbl...
Hi,

http://msdn.microsoft.com/library/de...nroletopic.asp
Ken
-----------------------------
"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
Hi everyone!
I am developing app, which should be used by users, which are members of
different groups.
These users and groups are stored in my SQL database and are custom for my
application, they are not Windows users.
Every user can be member of many groups.
What I need is a some kind of baseline, how to implement security in my app, based on these users and groups.
By security I mean enabling and disabling different functionality of my app, mosltly disabling controls.
Should I use some kind of ACL, or on every Form load event I should enable
or disable controls, based on the group membership of user.
Because I am a newbie, some source code will be helpfull.

TIA

Nov 21 '05 #4
Nikolay,

Just an idea for your problem nothing more.

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Select case UserGroep
case 1
Dim ctrArr As Control() = New Control() {Textbox1, Textbox2}
For Each ctr As control In ctrArea
ctr.visible = true
Next
case 2
End select
End Sub
///

And than not this exact code however store the arrays per Form in a
database, and read that for the proper user group, which then would be very
effective in my idea.

Cor
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David N | last post by:
Hi All, The OnLoad() event is invoked automatically when a form is being loaded. Do we have another event that is invoked automatically after a form has completed loading? Thanks.
7
by: Andy Bates | last post by:
I have hopefully a simple problem in C#. I designed a form with a listview on left, vert splitter against that, then the remainder of the form from top to bottom: a listview, horiz splitter and...
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: Jerry J | last post by:
Is there a way to change the background color of a web form on the server before it is posted? In the pageLoad event I can do it to server controls by adding an attribute, however, how do I do...
3
by: jm | last post by:
Right now, I have a MySQL database that has groups defined (not AD groups) and based upon which group a user is in they are allowed certain pages, controls, etc. I want to make my systems more...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
3
by: | last post by:
For a given web form, I want to know what the +simplest+ way to add an attribute to all of a particular control type on that page. For example, I might want to add an onClick attribute to all...
22
by: Victor | last post by:
Hi everybody! I am experiencing a strange - at least for me - phenomen. I have a func containing the following code : alert (document.forms.elements.value); // document.forms.submit();...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.