Community Tip - You can change your system assigned username to something more personal in your community settings. X
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.
Solved! Go to Solution.
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
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
Thankyou so much.
PS: SUB METHOD UtilTeam.GetUserGroup(...)
public static Vector<String> GetUserGroup(WTUser user, WTContainer container)
{
Vector<String> retValue = new Vector<String>();
try
{
Enumeration parentGroups = user.parentGroups();
while (parentGroups.hasMoreElements())
{
WTPrincipalReference wtref = (WTPrincipalReference) parentGroups.nextElement();
WTPrincipal wtAA = (WTPrincipal) wtref.getObject();
if (wtAA instanceof WTGroup)
{
WTGroup workGoup = (WTGroup) wtAA;
WTContainer groupContainer = workGoup.getContainer();
if (container != null)
{
if (container.equals(groupContainer))
{
retValue.add(workGoup.getName());
}
} else
{
retValue.add(workGoup.getName());
}
}
}
} catch (WTException e)
{
e.printStackTrace();
}
return retValue;
}//