Issue Summary: AddPermission() does not seem to work the first time it is used; $AccessLevel of the operator logged on to InTouch did not change.
Cause Description: THIS BEHAVIOR WORKS AS DESIGNED (WAD). The issue was reviewed and it was determined that the product was intentionally designed to behave in the manner described within the issue.
Resolution Summary: AddPermission() should be used before logging on a user that is a member of the affected group.
ISSUE: $AccessLevel is not updated on first login:
My application wants the operator to login/logout with a logged reason and to use the Windows 2000 security accounts on the HMI computer. I have a logon screen that lists the reasons in a combo box and then shows the login/logout button once a reason is selected. This button exectutes PostLogonDialog(). While the logon screen is running, every 250ms a script runs that uses AddPermission() and uses the current login information from PostLogonDialog().
We know that AddPermission() changes the $AccessLevel to whatever is written in its statement. However, at the first login of the system, AddPermission() doesn't seem to work and change the $AccessLevel. PostLogonDialog() does seem to work because the $Operator and $OperatorDomain are updated with the current information. When I logoff and log back in, the AddPermission() script does work and the $AccessLevel does change. Why doesn't it work during the first login? Please advise.
Development system: Win2KPro, WW8.0 SP2
SOLUTION: Do the AddPermission() before logging on a user in the affected group.
If a user is already logged in to InTouch, and I then use AddPermission() to assign an access level to the user's group, the $AccessLevel does not change. If I login again as the same user, the $AccessLevel does change. If I do the AddPermission() before logging in a user, the $AccessLevel updates as expected.
This is working as designed. From the InTouch Reference Guide:
Valid for OS security mode only. An attempt is made to reach the account Account located on domain Domain. If successful, a TRUE is returned and the access level iAccessLevel is assigned to the account in the internal records in InTouch for use during authorization when a user logs on. In all other cases, a FALSE is returned.
Here are two workarounds:
1. (Preferred) Either do the AddPermission() on application startup (before any user has logged in), or
2. Right after the AddPermission(), check if the currently logged on user is a member of the group that the permission was added to; in which case have the user logon again if the $AccessLevel doesn't match up.
For example:
DIM result AS INTEGER;
DIM domain AS MESSAGE;
DIM group AS MESSAGE;
DIM perm AS INTEGER;
domain = "MYDOMAIN";
group = "MyGroup";
perm = 9000;
msg = ""; {message tag that's displayed on the window}
result = AddPermission( domain, group, perm );
IF result == 1 THEN
result = QueryGroupMembership( domain, group ); {check if the currently logged on user is a member of the group}
IF result == 1 AND $AccessLevel <> perm THEN
msg = "Please logon again.";
result = PostLogonDialog();
ENDIF;
ENDIF;