Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Preconfiguration "Runtime users management"

Administrative management of users in runtime mode. The users with defined rights are saved in a CSV file and then in the application memory.
 
This preconfiguration can be activated when creating a new object (e.g. by "New object ..." in the local object menu or after pressing the Insert key after selecting the object) and is included in the group: " / Panels (PmaPanel) / Others examples".

This preconfiguration can be created in the object: PmaFolder, PmaRoot, PmaPanel or PmaWorkspace.

 
The preconfiguration is created including the panel (object of the PmaPanel type) is functional also a Web panel.
 
The preconfiguration creates three PmaPanel objects. The main panel is titled "AdminUsers" and has two subobjects:
The "EditUsers" panel represents a Modal window for adding new user or editin an existing one.
The "ChangePass" panel represents a Modal window for changing the password of current user.

All these objects have, on the "Permissions" tab, defined all items for the users from the $ADMIN group. The "AdminUsers" main panel serves for loading a table containing a user list and adding/editing them using the function buttons. The CreateView method is used for opening.

 
The main panel has the following methods:
Crypt - (complementary) for coding and decoding the user login password
GetGroup - (complementary) for loading the list of available user groups
GetUsers - (complementary) for loading the complete list of all users (saved in ini or pra file)
InitUsers - (essential) adds the users saved in the csv file into the running application
LoadUsers - (essential) loads the array containing all users with user rights from the csv file
SaveUsers - (essential) saves the array containing all users with user rights into the csv file
UserAdd - (essential) prepares the array for saving with the values updated from the user editing
UserChangePass - (essential) prepares the array for saving with modified value of password for selected user
UserRemove - (essential) prepares the array for saving without the values for deleted user

The basic essential method is InitUsers. It uses the AddUser method in order to add all users saved in the CSV file into the running application. This method is always called when modifications are being made to user list and it also has to be called at application launch. Designer's methods LoadUsers and SaveUsers serves for loading or saving all users together with their rights into the csv file. (It is possible to modify them in order to allow saving into some database table.) The EncryptText and DecryptText methods are used in the complementary Crypt method where the sSeed variable for coding and decoding the login password can be modified.

 
The main panel contains the PmgWTable object and some PmgButton buttons. In the onStart event of the table, there is a script used for filling in the table with the list of users gathered from the csv file. The script in the onCellClicked event allows to select a row. In the onCellEditRequested event, a new EditUsers window is opened for editing the selected user. Buttons of the PmgButton type contain the a script in the onButtonUp event, that executes the desired action.
 
The EditUsers panel is opened in the onCellEditRequested event of the table or from buttons Add or Edit. The panel itself contains PmgWEdit, PmgString, PmgButton and PmgWTable objects. In the onStart event of the table, each objects is filled with the data of the edited user. These can be edited as needed and the confirmed and saved by the OK button.
 
The ChangePass panel is opened from the main panel by the Change password button. The panel contains the PmgWEdit, PmgString and PmgButton objects. In the onStart event of the PmgButton object the original user login data is saved into the hidden Pmg objects. After the new user login data is entered and the OK pressed, the script compares the data and saves it.
These configurators can be set before the preconfiguration is created:
The name of created objectName of the object created in the tree of Pma objects. The maximum name length is 30 characters. This is a system name, so it must contain only alphanumeric and must not contain any diacritics, empty string, spaces and the first character must not be a number.

Default: "AdminUsers"

Object scripting languageApplication object scripting language
0 - vbscript
1 - javascript
PermissionsOn this tab permissions of the object are defined. See the "Permission" tab of the PmaObject object.
Member of logical groupsThe list of the identifiers of the logical groups (the comma ',' is the separator), the object belongs into (it is a group member), see Logical groups. The logical group selection can be done in the "Member of logical groups" window.

After the preconfiguration is created, the "PmaObject > Object > Member of logical groups" configurator will be set to this value.

File name for saving the user rightsThe file name for saving the users and their user rights (default) users
Password encryption stringstring, for example "xyz" is used as a seed for the EncryptText and DecryptText methods for crypting the user password.
Enable as Web componentSpecifies whether this object has to be registered as a Web server component

After the preconfiguration is created, the "PmaPanel > Web server > Enable as Web component" configurator will be set to this value.

Example1:
Example of calling the "InitUsers" method after application launch. The script must be placed into the onAppStartEnd event of the PmaRoot object.
pMe.Pm("AdminUsers").Methods.InitUsers
Example2:
Example of opening the AdminUsers panel in the onButtonUp event of the PmgButton object located in another panel. (The panel will be opened only by a user that is logged in and belonging to the $ADMIN group).
JavaScriptVBScriptSelect and copy to clipboard

Pm.CreateView(pMe.PmPanel, "/AdminUsers", "", "target:_blank;").Open();

History:
Pm8.00.03: Created
PROMOTIC 9.0.15 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice