Read User Groups from table USRGRP - SAP Direct

Finally I was able to read user groups from SAP system retrieving data from USGRP table.

For this case, I’ve noted that connector only retrieve roles and profiles from following objects:

Roles: AGR_FLAGS, AGR_PROF, AGR_TCODES, AGR_TEXTS
Profiles: USR11, UST10C

but I did not found any reference to retrieve data from USGRP table. So, for this case I have created a external task to retrieve data from this table, using a JCO connection.

  import sailpoint.object.ManagedAttribute;

  import com.sap.conn.jco.JCoDestination;
  import com.sap.conn.jco.JCoTable;
  import com.sap.conn.jco.JCoFunction;
  import com.sap.conn.jco.JCoParameterList;
  import com.sap.conn.jco.JCoDestinationManager;
  
  JCoDestination destination = JCoDestinationManager.getDestination(appName);
  JCoFunction function = destination.getRepository().getFunction("RFC_READ_TABLE");
  JCoTable inputTableParam = function.getTableParameterList().getTable("FIELDS");
  inputTableParam.appendRow();
  inputTableParam.setValue("FIELDNAME", "USERGROUP");
  JCoParameterList inputParamList = function.getImportParameterList();
  inputParamList.setValue("QUERY_TABLE", "USGRP");
  inputParamList.setValue("DELIMITER", ";");
  function.execute(destination);
  JCoTable table = function.getTableParameterList().getTable("DATA");

  List list = new ArrayList()
  if (!table.isEmpty()) {
	  table.firstRow();
	  do {
		  list.add(table.getString());
	  } while (table.nextRow());
  } 
  else {
	  log.trace("There is not userGroups in system " + appName);
  }

for (String item : list){
  ManagedAttribute ma = new ManagedAttribute();
  ma.setAttribute("User Group");
  ma.setValue(item); 
  ma.setRequestable(true);
  ma.setApplication(app);
  ma.setType("Entitlement");
  
  context.saveObject(ma);
  context.commitTransaction();
}
1 Like