Skip to main content
Mar 2, 2023 5:22 AM UTC
Solved

Find user license type programmatically

I'm working on a custom action which opens up a jsp when clicked. When the jsp opens, I want to check the users license type and allow only if the user has got a certain license type, for example - PTC View and Print Only. Please share me the snippet if anybody has done this earlier.

 

Mar 2, 2023 6:18 AM UTC

Hi @MV_10441462 

 

It is simple, you need to get a PTC License group and check if the user is in. 

 

or in my example there is opposite way.

 

get all groups that user is in and check if the collection contains your interest the PTC Lincence group 

 

example>

WTPrincipal realUser = SessionHelper.manager.getPrincipal();
Vector<String> groupsList = UtilTeam.GetUserGroup((WTUser) realUser, realUser.getOrganization().getContainer());

boolean isUserInSAPgroup = groupsList.contains("SAP_Group");
boolean isUserAdmin = groupsList.contains("Administrators");

// use the booleans in conditions. 

 

PetrH

3 replies

Mar 2, 2023 6:18 AM UTC

Hi @MV_10441462 

 

It is simple, you need to get a PTC License group and check if the user is in. 

 

or in my example there is opposite way.

 

get all groups that user is in and check if the collection contains your interest the PTC Lincence group 

 

example>

WTPrincipal realUser = SessionHelper.manager.getPrincipal();
Vector<String> groupsList = UtilTeam.GetUserGroup((WTUser) realUser, realUser.getOrganization().getContainer());

boolean isUserInSAPgroup = groupsList.contains("SAP_Group");
boolean isUserAdmin = groupsList.contains("Administrators");

// use the booleans in conditions. 

 

PetrH

Mar 2, 2023 6:27 AM UTC

Thankyou so much.