Load Web Security Values

Description

Populate the controls with data from the web security system.

Discussion

The Load Web Security Values action script populates a UX component with security info for a user. This action can be used to create an interface for updating a user's security settings in the web security system.

Properties 

The action is configured using the following properties:

  • Find User By 

    The security value used to look up the user. The preferred method is User Name.

  • Find by Value Source 

    The Xbasic variable that contains the value to use as the Find User By value. The variable must be defined prior to calling the action.

    Source
    Description
    local variable

    The value to use is defined in a local Xbasic variable defined in the function or event calling the Action Script. For example, dim userName as C = "[email protected]". userName would be the value entered in Find by Value Source.

    This option is often used in tandem with the Populate a Dialog with data from one or more table(s) action. The Populate a Dialog with data from one or more table(s) action is used to generate the Xbasic variable for use with the Load Web Security Values action. See example below for more info.

    session variable

    The value to use is a session variable. For example, session.userName. userName would be the value entered in Find by Value Source.

    request variable

    The value to use is a request variable. For example, e.rv.userName. userName would be the value entered in Find by Value Source.

    rtc variable

    The value to use is a runtime calculation variable. For example, e.rtc.userName. userName would be the value entered in Find by Value Source.

    argument

    The value to use is an argument defined in the component's arguments properties. For example, if you have defined an argument called "userName" set at runtime, userName would be the value entered in Find by Value Source.

  • User Name 

    The control in the component that contains the User Name or User Id. Repeating section controls are not supported.

  • Password 

    The control in the component that contains the user's password. Repeating section controls are not supported.

  • Confirm Password 

    The control in the component used to verify the user's password. The value is compared against the password entered in the Password control. Repeating section controls are not supported.

  • Security Groups 

    The control in the component that contains the user's security groups. Repeating section controls are not supported.

  • User Identifier (guid) 

    The control in the component that contains the user's security identifier. This control is usually hidden. Repeating section controls are not supported.

Example: Using the Load Web Security Values Action 

After you register a user into a web security system it is useful to be able to find and edit a record. This guide demonstrates how to use the load web security action. The process is also explained in this video, which is the third video in a series.

  • Build a Component with a Register and Personal Data Section 

    1. Build the Component described in the Validate Web Security guide and the Save Submitted Data to Table(s).

      images/lws2.png
  • Add New Security Groups to the Web Security Folder 

    1. From the Web Projects Control Panel click on the 'Web Security' button.

      images/lws20.png
    2. In the Web Security dialog click on the 'Users and Groups' option and click OK.

      images/lws21.png
    3. Open the 'Groups' tab and click the 'Add Group' button.

      images/lws22.png
    4. Name the new group 'Customer'.

      images/lws23.png
    5. Click the 'Add Group' button again and name the group 'Admin'. Click 'OK' and 'Close'.

      images/lws24.png
  • Set the UserRoles Control to be a Radio Button 

    1. Open the UX Component containing the Register and Personal Data Section. Highlight the [UserRoles] Hidden control.

      images/lws25.png
    2. Click the blue 'up' arrow in the Controls page toolbar to move the hidden control inside the 'Register' frame container.

      images/lws26.png
    3. With the [UserRoles] control highlighted view the properties list on the right. Click the button next to the 'Control type' property.

      images/lws27.png
    4. Select the 'RadioButton' control type.

      images/lws28.png
    5. Scroll down to the 'Field Properties' section and set the 'Width' property to be '4.5in'.

      images/lws29.png
    6. Scroll down to the 'RadioButton Properties' section. Click the button next to the 'Choices' property.

      images/lws30.png
    7. Select the 'Variable' radio button option in the dialog that opens. Set the 'Variable name' to be 'UserRoles'.

      images/lws31.png
  • Add a Load Web Security Values Action to the onDialogInitialize Event 

    Once a record in the registered users table is found, the username in the record will be used to find the related security record. In the onDialogInitialize event a variable must be passed to the dialog to find the user in the registered users table. In this example this is a variable named id. A e.rtc variable is set up to populate the radio control for the UserRoles or user groups. The a5ws_GetGroupsDialog() is used to populate the variable. This function is specifically designed to be used in the dialog events.

  • An action script will be used to populate the data from the registered users table. This action uses the variable named 'id' as its primary key source. In the "Populate Dialog with Data from One or More Table(s)" action's properties sheet the 'Capture raw data' property is also checked. In this example the username and registered user data are used to capture to related security record. We need to capture that value in a variable after the record is found. This data will be returned with a variable name "_data" plus the field name, which will be the username. Finally we will add an action to load the security data. With the Load Web Security Values action The preferred value to use is username. You can find the source for the value using a number of options, here we will use the 'local variable' option.

    1. Expand the 'Events' menu and open the 'Server-side' events page. In the 'Server-Side Events' list highlight the 'onDialogInitialize' event.

      images/lws3.png
    2. Add the following lines of code to the event definition.

      dim id as c = "1"
      dim e.rtc.UserRoles as c
      e.rtc.UserRoles = a5ws_getgroupsdialog()
      images/lws4.png
      Here we are adding the 'id' variable and then e.rtc variable uses this to populate the radio control buttons with the 'UserRoles', or groups, option.
    3. Place the mouse cursor just below the newly entered line of code and click the 'Action Scripting' button.

      images/lws5.png
    4. Highlight the "Populate a Dialog with data from one or more tables" action and click OK.

      images/lws6.png
    5. Name the action 'Load_User' and click OK.

      images/lws7.png
    6. In the action's settings genie, set the 'Primary key source' dropdown to be 'ReadFromVariable'.

      images/lws8.png
    7. Set the 'Variable that contains the primary key' property to be the variable 'id'.

      images/lws9.png
    8. Check the 'Capture raw data' checkbox.

      images/lws10.png
    9. Next to the 'Dot variable name for captured data' property type '_data'. Click OK to close the settings genie.

      images/lws11.png
    10. Place the mouse cursor under the "Populate Dialog from Tables" action and click on the "Action Scripting" button a second time.

      images/lws12.png
    11. From the list of actions, highlight the 'Load Web Security Values' action and click OK.

      images/lws13.png
    12. Give the new action the name 'Load_Security'. Click OK.

      images/lws14.png
    13. In the 'Load Web Security Values' action's settings genie click the dropdown next to the 'Find User By' setting. Select the 'User Name' option.

      images/lws15.png
    14. Click the button next to the 'Find by Value Source' setting.

      images/lws16.png
    15. Select the 'local variable' radio button option. Give the local variable the variable name '_data.USERNAME'. Click OK.

      images/lws17.png
    16. Click the 'Load Saved Values' hyperlink at the bottom left-hand corner of the settings genie. This will automatically fill in the 'Assign Variables to Security Variables' section; assuming that the component in the . Click OK.

      images/lws18.png
    17. Resulting event definition.

      images/lws19.png
  • Run the Component in Working Preview 

    1. Run the component in working preview. Fill in the Personal Data and Register sections of the component.

      images/lws32.png
    2. Click the 'Submit' button.

      images/lws33.png
    3. Open the Design tab and then return to 'Working Preview'. You should see that all of the fields that appear in the registered users table, for the user you defined, will be loaded into the component.

      images/lws34.png

See Also