Click here to Skip to main content
15,879,474 members
Articles / Programming Languages / Visual Basic

RestrictedUI: A .NET Library for restricting a user interface based on a security policy

Rate me:
Please Sign up or sign in to vote.
4.30/5 (17 votes)
26 May 2010MPL21 min read 26.7K   1.3K   69  
How to control the user interface using a policy established in a declaratively way, based on user roles and application status.
[Factories]
; Relative paths will be expressed in relation to the folder containing the solution (. sln). This path will be used to locate the DLL in design time. 
; We will assume that the DLL is in the same folder as the executable, so in runtime the path will be ignored and used only the name of the file
; Note: You may also use absolute paths.

[CommonRoles]
99,Administrator,Adm
10,Director,Dtor
20,Consultant,Cons

[CommonStates]
0,Initial
1,Pending Validating
2,Validated

;=======================================================
[SECURITYCONTROL=Form1]
[Roles]
30,Auxiliar,Aux

[States]
3,Special State

[Groups]
Group Disable Buttons= gbCommands.btnDisableEnabled, gbCommands.btnDisableVisible
Group Enabled Buttons= gbCommands.btnEnableEnabled, gbCommands.btnEnableVisible, gbCommands.btnEnableVisible_N
Group Trees= TreeView1

[Restrictions]
+123/TextBox,V,2
+Adm/$Group Trees,E/MenuStrip1.EditToolStripMenuItem.CutToolStripMenuItem,V
+Dtor/GroupBox1.CheckBox1,V
-0/MenuStrip1.FileToolStripMenuItem.NewToolStripMenuItem,E/ToolStrip1.ToolStripComboBox1,E/ToolStrip1.ToolStripSplitButton1,E
-Aux/cControls.Name,V,1,2,3/$Group Enabled Buttons,V
-Cons/combo,V/$Group Disable Buttons,E

;=======================================================
[SECURITYCONTROL=Form2_Sub1]
[Roles]

[States]

[Groups]
Group 0= CheckBox1, TextBox1
Group 1 - new group= Button1, TextBox1

[Restrictions]
+0/$Group 0,E
-0/CheckBox1,E/Button1,E

;=======================================================
[SECURITYCONTROL=Form2_sub2]
[Roles]
123,My Role 1,MyR1

[States]
77, State 77

[Groups]

[Restrictions]
-0/TreeView1.Node0.Node1,E/TreeView1.Node3.Node4.Node5,V

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Mozilla Public License 1.1 (MPL 1.1)


Written By
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions