Import users from another project

Introduction

This tutorial shows how, using OPC UA communication, to import and keep synchronized the users managed in another project.

The server project contains the users, who can be added/changed/deleted using a dedicated editor. The client project connects to the server to import and synchronize the users.

To create the user editor and the access panels, two predefined Q Studio widgets are used, which sets their user interface and basic mechanisms.

Download the example projects from here.

Steps

  1. Create server and client projects

  2. Server: configure users and the user editor interface

  3. Client: configure importing and the access panel

  4. Check operation

Create server and client projects

  1. Create a new standard project named ServerProject. The project already contains an OPC UA server object, which displays all the project nodes if there are no specific settings.

  2. Create another new standard project called ClientProject*.

    Hint

    before proceeding, remove the OPC UA Server object in the OPC-UA project folder as it is not needed for this tutorial.

Server: configure users and the user editor interface

  1. In the Users folder, create a DomainUsers folder. In it, create two users, Alice and Frank with it-IT and en-US locales, respectively.

  2. Open the template library and drag the user Editor widget into the UI folder.

  3. In MainWindow create the UserEditorOverview panel of the widget (New > UserEditor1 > UserEditorOverview): a UserEditorOverview1 panel is created.

  4. To associate the user editor with the user folder, in the UserEditorOverview1 properties, point the Users alias to the DomainUsers folder.

  5. (Optional) To verify access at runtime, perform the following steps:

    1. Open the template library and drag the Access module widget into the MainWindow object: the LoginForm1 panel is created.

    2. To associate the access module with the configured users, in the LoginForm1 properties, point the Users alias to the DomainUsers folder.

    3. Execute the server project and check the users have access.

Client: configure importing and the access panel

  1. In the Users folder, create a RemoteUsers folder, into which the users are imported from the server.

  2. Create a Client OPC-UA object in the OPC UA folder (New > OPC UA Client): the ClientOpcUa1 object is created.

  3. In the Endpoint URL server property of ClientOpcUa1, enter the endpoint of the OPC UA Server object present in the server project.

  4. In the ClientOpcUa1 properties, add a runtime configuration (see Configure the import of the nodes at runtime) and set its properties as follows:

    • Local destination node: Users/RemoteUsers

    • Remote source node: /Objects/ServerProject/Users/DomainUsers, i.e. the path of the DomainUsers folder on the server at runtime.

    • Content synchronization mode: Complete synchronization, necessary to keep the client updated when users are added/deleted on the server.

    • Include remote source node: False, to import user nodes only, excluding the DomainUsers folder node.

  5. Open the template library and drag the Access module widget into the MainWindow object: the LoginForm1 panel is created.

  6. To associate access module with the configured users, in the LoginForm1 properties, point the Users alias to the RemoteUsers folder.

Check operation

Start, in order, the server project and the client project to verify the following:

  • The users Alice and Frank have access on the client.

  • Changing the password of a user on the server, that user’s access is made on the client with the new password.

  • Configuring a new user on the server using the user editor, the same user is available for access on the client also.