cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Find user license type programmatically

MV_10441462
12-Amethyst

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.

 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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;
}//

 

Announcements

Top Tags