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

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

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

cd suthar,

can you please post your report here in the community?

Thanks

Marco

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

Hi Suthar,

Could you please share the report with me as well on wasim.b.ahmed@accenture.com?

thanks,

Wasim

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

Wasim,


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

Hope it helps !!!

Thanks

Shreyas

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.org.OrganizationServicesHelper;

import wt.org.WTGroup;

import wt.org.WTPrincipal;

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);

  qs.appendWhere(sc1);

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

  while (qr.hasMoreElements()) {

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

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

  continue;

  }

  if (!group.isDisabled()) {

  System.out

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

  + group.getName());

  groupMembers.test(group.getDn());

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

  }

  }

  } catch (WTException ex) {

  ex.printStackTrace();

  }

  }

  @SuppressWarnings("deprecation")

  public static void test(String name) throws WTException {

  WTPrincipal principal = OrganizationServicesHelper.manager

  .getPrincipalByDN(name);

  if (principal == null) {

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

  return;

  }

  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")){

  continue;

  }

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

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

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

  } else {

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

  }

  }

  }

}

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

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

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

Shreyas,

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?

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

Is it grabbing only the Site or Org groups?

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

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

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

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:
        wt.method.AuthenticationException
        at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:810)
        at wt.services.ServiceFactory$ClientInvocationHandler.invoke(ServiceFactory.java:349)
        at com.sun.proxy.$Proxy1.find(Unknown Source)
        at sh.GroupMembers2.main(GroupMembers2.java:28)

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group