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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Extract all Groups, user and its profile related information by java code


Extract all Groups, user and its profile related information by java code

Hi All,

i need to extarct all Groups, Group Member and user related information in tabular manner by using java code.

Please any one give me some idea how i can achive this requirement.



22-Sapphire I

Every Windchill system admin needs this. This exact question has been posted to the world at least 1,000,000,000 times that I'm aware of. It's pretty incredible that at release 10.x PTC has not provided any way to extract this info. We paid a consultant to create a report. Others export from Windchill DS and parse in innovative ways in Excel.

The needed info is at Org, Groups (or possibly Site, Util, Participant admin). There is just no way to output the results currently.

Vivek, if you are familiar with customization, you can use the Windchill APIs (refer to Windchill javadoc) to write a java class that extracts this information in a required format. You can look for helper and service apis related to WTUser, WTPrincipal, WTGroup classes along with the QuerySpec.

Another option is to create a custom report using Query Build (Report Manager), but that is way too complex. You might want to consider it only as last resort.

Query Builder can't reach into LDAP.

True, Mike. But every LDAP user who once logs into Windchill would have an entry in the windchill database table, from where you can query the record, using either query builder or java code.

Agree on the wtuser and wtgroup tables - but the key thing is not being able to get group membership from the database via query builder.

Right. Thats where using the query builder becomes complicated!

Using java code - We can query all the groups using QuerySpec apis, and then for each group, we can use the WTGroup.members() method to get an enumeration of all the group members.

I'm very interested in getting a report still that lists users and what groups they are in. The report we paid for gets confused when groups are nested and we highly nest them. Do have this available and can you share to

I'll happily supply anything we have that you are interested in.


Unfortunately, I dont have this available, but here is what you can do:

1. Query all the groups from the database using QuerySpec apis (you can search for QuerySpec in Windchill javadocs).

2. For each group, get all the members using WTGroup's members() method.

3. What you would get in the enumeration would be a WTPrincipal reference, and a WTPrincipal could either be a WTUser or WTGroup. If the it is WTUser, you have got a user and if its WTGroup, you have got a nest group and can get the members for this group too.




Mike I will send you Report..

cd suthar,

can you please post your report here in the community?



Hi Suthar,

Could you please share the report with me as well on





Below code will extranksct/Print  the Organization > Group tables.

Hope it helps !!!



package ext.sra;

import java.lang.reflect.InvocationTargetException;

import java.rmi.RemoteException;

import java.util.Enumeration;

import wt.fc.PersistenceHelper;

import wt.fc.QueryResult;




import wt.query.QuerySpec;

import wt.query.SearchCondition;

import wt.util.WTException;

public class groupMembers {

  public static void main(String args[]) throws WTException, RemoteException,

  InvocationTargetException {

  QuerySpec qs = null;

  try {

  qs = new QuerySpec(WTGroup.class);

  SearchCondition sc1 = new SearchCondition(WTGroup.class,

  WTGroup.INTERNAL, SearchCondition.IS_FALSE);


  QueryResult qr = PersistenceHelper.manager.find(qs);

  while (qr.hasMoreElements()) {

  WTGroup group = (WTGroup) qr.nextElement();

  if (group.getName().equals("ORG ADMIN")){



  if (!group.isDisabled()) {


  .println("\n\n ===========================\nGroup Members pf Group  -->   "

  + group.getName());


  System.out.println("\n\n ===========================\n");



  } catch (WTException ex) {





  public static void test(String name) throws WTException {

  WTPrincipal principal = OrganizationServicesHelper.manager


  if (principal == null) {

  System.out.println("Principle not found###" + name);



  Enumeration parents = OrganizationServicesHelper.manager.members(

  (WTGroup) principal, false);

  while (parents.hasMoreElements()) {

  WTGroup gr = null;

  WTPrincipal parent = (WTPrincipal) (parents.nextElement());

  if (parent.getClass().isAssignableFrom(WTGroup.class)) {

  System.out.println("--------" + parent.getName());

  if (parent.getName().equals("ORG ADMIN")){




  // System.out.println("-->" +

  // test(parent.getName().toString()));

  } else {

  System.out.println("--------" + parent.getName());






Thanks a lot Shreyas. I'll give a try and let you know the results.


Thank you so much, this really helps. But one question i'm able to fetch details of only 50 groups using the code whereas my Windchill instance has around 145 Unique groups in it.

I ran a DB query of "Select DISTINCT NAME from WTGROUP;" which gives me 145 groups, but when i run this code the code fetches details of 50 Groups only. Any pointers?

Is it grabbing only the Site or Org groups?

This is because WTGroup stores internal group table information as well, which are not LDAP group byt context roles

While running this code I get the following error. please help.


D:\ptc\Windchill>windchill sh.GroupMembers2 "AAV SU ARES Guests"
(wt.fc.fcResource/0) wt.util.WTException: The operation:   "find" failed.
Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method;
nested exception is:
        at wt.method.RemoteMethodServer.invoke(
        at com.sun.proxy.$Proxy1.find(Unknown Source)
        at sh.GroupMembers2.main(

Top Tags