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
Create server and client projects
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.
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
In the Users folder, create a DomainUsers folder. In it, create two users, Alice and Frank with it-IT and en-US locales, respectively.
Open the template library and drag the user Editor widget into the UI folder.
In MainWindow create the UserEditorOverview panel of the widget (New > UserEditor1 > UserEditorOverview): a UserEditorOverview1 panel is created.
To associate the user editor with the user folder, in the UserEditorOverview1 properties, point the Users alias to the DomainUsers folder.
(Optional) To verify access at runtime, perform the following steps:
Open the template library and drag the Access module widget into the MainWindow object: the LoginForm1 panel is created.
To associate the access module with the configured users, in the LoginForm1 properties, point the Users alias to the DomainUsers folder.
Execute the server project and check the users have access.
Client: configure importing and the access panel
In the Users folder, create a RemoteUsers folder, into which the users are imported from the server.
Create a Client OPC-UA object in the OPC UA folder (New > OPC UA Client): the ClientOpcUa1 object is created.
In the Endpoint URL server property of ClientOpcUa1, enter the endpoint of the OPC UA Server object present in the server project.
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.
Open the template library and drag the Access module widget into the MainWindow object: the LoginForm1 panel is created.
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.
See also
Related concepts
OPC UA communications security
Related procedures
How to use an OPC UA Client object
Use OPC UA certificates and keys
References