cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
774
Views
0
Helpful
1
Replies

List users from specific group

Hello,

Does anyone know how to list users in a group? I would like to create a workflow to deploy VMs for all users in a group. I do not want to define the numer of cloned VMs as input variable, just the group name. The workflow shoud fetch all users from the group, create the VM, and assign it to the user. I searched for some sample code on te Index page, but neither one fits. Thanks in advance.

Best regards,

Krzysztof

1 Reply 1

I managed to handle this. In case someone has similar needs, here is the hint (just an excerpt from the script):

 

// common report handling functions ommited for brevity

var inputGroupId = input.InGroupId;

var groupReportName = "AccountsFeature.group.table_config";
var groupReportContext = util.createContext("global_admin", null, null);
var groupReport = getReportView(groupReportContext, groupReportName);
groupReport = groupReport.filterRowsByColumn("Group ID", inputGroupId, false);
if (groupReport.rowCount() != 1)
{
  logger.addError("Group with ID [" + inputGroupId + "] not found!");
  ctxt.setTaskStatusMessage("Group with ID [" + inputGroupId + "] not found!");
  ctxt.setFailed("Group with ID [" + inputGroupId + "] not found!");
  exit;
}
else
{
  var groupName = groupReport.getColumnValue(0, "Group Name");
  logger.addInfo("Group ID [" + inputGroupId + "] is [" + groupName + "]");

 

  var userList = "";
  var userReportName = "AccountsFeature.user.table_config";
  var userReportContext = util.createContext("global_admin", null, null);
  var userReport = getReportView(userReportContext, userReportName);

  userReport = userReport.filterRowsByColumn("User Group", groupName, false);
  logger.addDebug("*** Found users [" + userReport.rowCount() + "]");

  for (i=0; i<userReport.rowCount(); i++)
  {
    var userName = userReport.getColumnValue(i, "Login Name");
    logger.addDebug("*** Found user [" + userName + "]");
    userList = userList + userName + ",";
  }
  // Remove last coma
  userList = userList.substring(0, userList.length()-1);

 

  output.OutUserList = userList;
}

 

Now, you can pass OutUserList to the Start Loop task for iteration.

 

Cheers,

Krzysztof

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Cisco UCS X-Series Energy Efficiency Offer