Promotic

onUserLogonBegin - event of the PmaRoot object

Description:
The event is triggered on an attempt to log in the user into the running application after the user entered the login name and password.
The PROMOTIC application checks the validity in the list of users and then this event is triggered with parameters in the pEvent object preset according to the fact if the name and password have been found in the list or not.
By this way it is possible to enable or disable the log-on of the user even according to other criteria than are covered in the standard log-on processing. So it is possible, for example, to create self-lists of users saved in the INI file with encrypted passwords (Pm.IniFileRead, Pm.IniFileWrite, Pm.EncryptText and Pm.DecryptText).
Parameters:
pMe(Object) Reference to the PmaRoot object where the event rises.
pEvent(Object) Reference to the object describing detailed information about the specific event.
pEvent.User - (Object) [for reading] The PmUser object that represents the user being logged in.
pEvent.UserId - (String) [for read and write] Identifier of the logged-in user. The value je preset if the login name entered by user is found in the list of users.
pEvent.Name - (String) [for read and write] Name of the logged-in user. The value je preset to the name entered by the user.
pEvent.Password - (String) [for read and write] Password of the logged on user. The value je preset to the password entered by the user.
pEvent.Error - (Long) [for read and write] Specifies which information is not correct. According to the current value a warning - invalid user name or password - is eventually displayed after the event is completed. The value can be changed and modify the displayed warning.
0 - User name and password are valid.
1 - User name is not valid.
2 - Password is not valid.
pEvent.Enabled - (Boolean) [for read and write] Enable/disable the log-on of the user. The value je preset according to the validity comparison of entered data with the list of users. If the value of the property is true, then the log-on of the user is enabled. Otherwise the value of the property is false. By this way it is possible, for example, to enable (disable) the log-on of the user from the list of users who in normal circumstances couldn't (could) be logged on.
pEvent.Level - (Integer) [for read and write] (obsolete) The level of the user. The value je preset according to the validity comparison of entered data with the list of users. The level of the logged-in user can be entered or changed by this way (doesn't need to be set from the list of users).
Note:
The event is triggered for every user (both local and network). Deatiled user information (PmUser object) are avilable in the pEvent.User parameter.
Example1:
If needed to execute some code only for local users, then it is possible to test the values of the PmUser.Type property.
JavaScriptVBScriptSelect and copy to clipboard

if (pEvent.User.Type == 1)
{
// ... The code executed only for local users
}
Example2:
Refusal of new network user login if user with the same Id is already logged in.
JavaScriptVBScriptSelect and copy to clipboard

var iUser;
var aUsers = Pm.GetUserInfo("what:loguserarray;type:net;");
var nUsers = aUsers.GetSize(1);

for (iUser = 0; iUser < nUsers; iUser++)
{
if (aUsers.GetItem(iUser).Id == pEvent.UserId)
{
pEvent.Enabled = 0;
}
}
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.