Using Toolbarsecurity with a Security Framework (like Dynamics, Dynamics4.NET)


The SmartComponent Libraries Toolbar (SmartToolbarController) is equipped with the ability to maintain security for the TableIO Actions in relation to each individual TableIOTarget (Viewer or Browser).  

This is designed to allow to be plugged into an existing security framework like Progress Dynamics or Consultingwerk's Dynamics4.NET or a customers own framework.  

The SetTableIOActionDisabled method of the SmartToolbarController class

The SmartToolbarController has a public method SetTableIOActionDisabled which is like this:  

METHOD PUBLIC VOID SetTableIOActionDisabled (poSmartTableIOTarget AS ISmartTableIOTarget,
                                             poTableIOAction AS TableIOActionEnum,
                                             plDisabled AS LOGICAL):


(TableIOActionEnum is a class defined in the package Consultingwerk.SmartComponents.Enum.*)  

The parameter poSmartTableIOTarget is the reference to the TableIO Target (a SmartViewerControl or SmartUpdatableBrowser) for which you want to enable or disable an action.  

The poTableIOAction parameter sets the action you want to enable or disable. Valid setting are:  

  • TableIOActionEnum:Add 

  • TableIOActionEnum:Cancel 

  • TableIOActionEnum:Copy 

  • TableIOActionEnum:Delete 

  • TableIOActionEnum:Save 

  • TableIOActionEnum:Update  

The plDisabled parameters controls if you want to lock down the action (disabled) or not. To disable a button in the Toolbar, pass in TRUE.  

Example of using SetToolbarActionDisabled with Dynamics4.NET

Dynamics4.NET wraps access to the Dynamics managers (like the Security Manager) into static classes.  

This is a sample code fragment from a Forms constructor that disables the modify button for customerViewer1 based on the security settings for the Form. RepositoryFormName needs to be replaced with the name of the Form in the Dynamics repository.  


ASSIGN cRestricted = Consultingwerk.Dynamics.Manager.SecurityManager:TokenSecurityGet (?, "RepositoryFormName", "") . 


The Variable cRestricted will contain the comma-delimited list of restricted actions.  

To make the Toolbar react on this, use code like this:  

IF CAN-DO (cRestricted, "Modify") THEN
    smartToolbarsController1:SetTableIOActionDisabled (customerViewer1, Consultingwerk.SmartComponents.Enum.TableIOActionEnum:Update, TRUE).

In a larger application we recommend to automate this code in a custom Form base class or derived SmartToolbarController class.