Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

VisuUserManagement.g_VisuUserMgmt2 : How to use this function

kebek007
2021-06-21
2021-06-21
  • kebek007

    kebek007 - 2021-06-21

    Hello Codesys community,

    I'm trying to create a function that disables user management by logging in the user to a user group with full control. Since I am using my own library elements, it has been challenging to work with the VisuUserManagement STL Functions and Im getting slowly frustrated :D .

    The logout, login and the others work fine. However the logging in to specific User Groups has been failing. Can someone tell me what is wrong here ? Can someone explain to me the arr[] Data, What should I put there ??? ( I have oriented myself on previous answers and the project KeySwitch_VisuClient_Change_v1.project)

    I have 4 User Groups defined in user management:
    ID Usergroup
    1 -> Administrator
    2 -> Maintenance
    3 -> Operator
    5 -> Supervisor -> (Username: Service)
    .. -> None

    // Get Client information based on client
    pClient := VisuElems.VisuElemBase.g_ClientManager.GetClientData(CurrentClientID);
    IF pClient <> VisuElems.NULL THEN
    
    
        IF (pClient^.GlobalData.CurrentUserGroupId <> 5) THEN 
    
                    arr[0] := 1; 
                    arr[1] := 2;
                    arr[2] := 3;
                    arr[3] := 5; 
                    VisuUserManagement.g_VisuUserMgmt2.LoginToUserGroups(pClient, ADR(arr), 4, "Supervisor","Service"); 
        END_IF 
    
    
            n_xUserManagementActive := FALSE;
    END_IF
    

    When I call this function, it logs out to UsergroupID 0 and doesn't login to the supervisor user group. The only part I don't understand is the arr[] Array. Im not sure what I need to put there. Can someone advise ?

    Thanks

     
  • kebek007

    kebek007 - 2021-06-21

    So I have found the problem. I was calling the UserMgmtEventHandler and for some reason it was logging out as soon as I called the function. I removed the implementation of the HandleLogout function and now seems to be stable.

     

Log in to post a comment.