Visualization WebVisu - Access to user group IDs

Hello,

I’m trying to access the group IDs of the connected user. “CurrentUserGroupId” var shows only the first group ID that the user is assigned, I need the other group IDs that the user is in.

I find some structs but I can’t find where they are used, like “VUM_User” scruct from visuusermgmt, where can I find this vars?

abyUserGroupIDs seens perfect but I can’t find a GVL where it is used.

Hi,
I only have an example of how you can get the information in the programme code for all active clients.

client_iteration.project (611.1 KB)

2 Likes

Thank you so much for your assistance, I just added some code to clean the addional group ids whena user logout or disconnect, and created a var to get the first group id found (default UserGroupId var)

FB_Iteration.HandleClient

IF iNumberOfVisuClients <= (VISU_MAX_NUMBER_OF_CLIENTS - 1) THEN
	
	astClientInfo[iNumberOfVisuClients].sIpAddress 		:= itfClient.GetIPv4Address();
	astClientInfo[iNumberOfVisuClients].stCurrentVisu 	:= itfClient.CurrentVisuName;
	astClientInfo[iNumberOfVisuClients].ClientName 		:= itfClient.GetClientName();
	astClientInfo[iNumberOfVisuClients].ClientType 		:= itfClient.ClientType;
	astClientInfo[iNumberOfVisuClients].iClientID 		:= itfClient.ClientId;
	astClientInfo[iNumberOfVisuClients].wsUserName 		:= itfClient.UserName;
	astClientInfo[iNumberOfVisuClients].dwUserGroupId 	:= itfClient.UserGroupId;
	
	IF __QUERYINTERFACE(itfClient, IClientRaw) AND_THEN IClientRaw.ClientDataPointer <> 0 THEN 
		astClientInfo[iNumberOfVisuClients].ClientDataPointer := IClientRaw.ClientDataPointer; // can be used to execute advanced functions
 		astClientInfo[iNumberOfVisuClients].abAdditionalUserGroupIds := IClientRaw.ClientDataPointer^.GlobalData.CurrentAdditionalUserGroupIds;

		astClientInfo[iNumberOfVisuClients].tAutoLogoutTime := T#0S; // clear 
		IF itfClient.UserName <> "" THEN
			astClientInfo[iNumberOfVisuClients].tAutoLogoutTime := 	(	IClientRaw.ClientDataPointer^.GlobalData.AutoLogoutTime -
																		(IClientRaw.ClientDataPointer^.GlobalData.LastUsage - IClientRaw.ClientDataPointer^.GlobalData.AutoLogoutTimeStart) );
		ELSE
			FOR j := 0 TO VisuUserManagement.VUM_Constants.VISU_VUM_MAX_GROUPS_PER_USER BY 1 DO
				astClientInfo[iNumberOfVisuClients].abAdditionalUserGroupIds[j] := 0;
			END_FOR;												
		END_IF
	END_IF
    iNumberOfVisuClients := iNumberOfVisuClients + 1; // Number of visu clients
END_IF

FB_Iteration.EndIteration

FOR _iCounter := (VISU_MAX_NUMBER_OF_CLIENTS - 1) TO iNumberOfVisuClients BY -1 DO
	
	astClientInfo[_iCounter].sIpAddress 		:= '';
	astClientInfo[_iCounter].stCurrentVisu 	:= '';
	astClientInfo[_iCounter].ClientDataPointer := 0;
	astClientInfo[_iCounter].ClientName := '';
	astClientInfo[_iCounter].ClientType := vu.visuclienttype.Unknown;
	astClientInfo[_iCounter].iClientID := -1;
	astClientInfo[_iCounter].tAutoLogoutTime := T#0S;
	astClientInfo[_iCounter].wsUserName := "";
	astClientInfo[_iCounter].dwUserGroupId := 0;
	FOR j := 0 TO VisuUserManagement.VUM_Constants.VISU_VUM_MAX_GROUPS_PER_USER BY 1 DO
		astClientInfo[_iCounter].abAdditionalUserGroupIds[j] := 0;
	END_FOR;

END_FOR

And now it’s everything working, thank you Patrick

1 Like

Thank you, perfect! I had forgotten that

1 Like