and tried to control them from the “watch”. First I’ve logged in with MpUserXLogin with an admin user successfully through the watch. Both MpUserXLoginConnectType and MpUserXMgrUIConnectType contain variables to change password, which of these should be used and what is the step by step to use it? When I’ve fill in the user data and change confirm to true nothing happens.
Furthermore, I would also like to save all the users for backup purposes, in a structure or file. I have found that MpUserXMgrUIConnectType contains types for import and export. Is there a simple way to use this from the back end code to export users, encrypt the passwords, decrypt and import again?
In both these cases I still want the user to also be able to add/delete/change users from the HMI. I have the mapp View widget UserList and login in the HMI and it works fine to both add users through there and still see the users in the MpUserXMgrUIConnectType if I log in with MpUserXLogin from an application session.
Are you opening the dialog before trying to confirm? Usually, when setting Confirm you should get at least a warning/error (if something went wrong) or the password has changed (in which case the dialog will just close). Please note that all mapp Services function blocks with “UI” in their names are meant to be used from VC4 visualizations and so are not necessarily intuitive from a code-perspective.
Either way, a very small example to change the password would be (Pseudo-Code; untested):
SWITCH (someStepVariable) OF
SHOW_DIALOG:
(* Note: Before trying to show a dialog, a user has to be logged in! *)
uiConnectLogin.ChangePassword.ShowDialog := TRUE;
loginUI();
IF (uiConnectLogin.Status = mpUSERX_UI_STATUS_WAIT_DLG) THEN
someStepVariable := someStepVariable + 1;
END_IF;
FILL_INFO:
uiConnectLogin.ChangePassword.Dialog.OldPassword := "asdf";
uiConnectLogin.ChangePassword.Dialog.NewPassword := "asdf";
uiConnectLogin.ChangePassword.Dialog.ConfirmPassword := "asdf";
loginUI();
uiConnectLogin.ChangePassword.Dialog.Confirm := TRUE;
someStepVariable := someStepVariable + 1;
WAIT_FOR_DONE_OR_ERROR:
(* Keep calling the FB until the status changes... This may/will take more than one cycle! *)
loginUI();
IF (uiConnectLogin.Status = mpUSERX_UI_STATUS_ERROR) THEN
(* Handle error case. Note: If you 'Confirm' or 'Cancel' the message box, the password dialog will "re-open". *)
(* The error will be written into 'uiConnectLogin.MessageBox' *)
ELSIF (uiConnectLogin.Status = mpUSERX_UI_STATUS_IDLE) THEN
(* Handle success case *)
END_IF;
END_CASE;
Keep in mind: If a dialog is not open the FB will ignore the complete dialog structure, which may seem/appear like the FB does nothing!
As for the difference between MpUserXManagerUI and MpUserXLoginUI. The MpUserXLoginUI is always “editing” the currently logged in user (and is therefore also limited to changing only “your own” password). The MpUserXManagerUI on the other hand is providing a management interface (for administrators) and allows changing passwords of other users (not only your own).
So if you don’t need “management” capabilities from the backend application code, I would suggest to use the MpUserXLoginUI.
I hope this information helps you in choosing the (for you) correct FB and implement the password changing correctly.
And regarding the Export/Import, I don’t have anything to add to @Alexander.Hefner. (Except maybe the hint that MpUserX never exports passwords un-encrypted! They are always encrypted/hashed and you will never see clear-text passwords in the export file.)