Knowledgebase: How to integrate
When code has to be added?
Posted by z Jean-jacques Jouanneaux on 17 August 2010 11:12 PM
Does the site need any code to be able to appropriately modify its user interface to properly support the permissions?
In most cases, Visual Guard .Net can dynamically modify the user interface without adding code. For instance, the sample installed with the product does not need code to be adjusted according to the user's permissions. All of the actions which modify the user interface are defined in the Visual Guard .Net console.
However, in some cases you need to add code in your application:
* When the objects are dynamically created and are not accessible through a variable (like the columns of a GridView)
* When the action depends on a permission and on data of the application in the same time. For example, you want to hide the wages of the employees you are not responsible for.
* When you want to modify a treatment of your application according to permissions.
In this case, the best thing to do is to add a new property to your class and to modify the value of this property by creating an action in Visual Guard.
For example, you have to create a Boolean property "ShowOnlySalaryForMyDepartment" and test this value in your class. In Visual Guard, you have to create an action which will modify the property "ShowOnlySalaryForMyDepartment" according to the permissions.
This way you can totally separate the permission management from the codding.
It is possible as well to create a permission "script" directly in Visual Guard, or to test whether a role or a permission is attributed to the user directly in your code. "Script" actions allow you to dynamically run code defined in the Visual Guard console, into your application.
Visual Guard .NET - Version 2.5.708.06