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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Translate the entire conversation 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
HelesicPetr
22-Sapphire II
(To:MV_10441462)

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
HelesicPetr
22-Sapphire II
(To:MV_10441462)

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.

HelesicPetr
22-Sapphire II
(To:HelesicPetr)

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