Scripting question: How do I get the list of groups that a user belongs to?
Hi...
I have a script that executes the command: "aa user --groups myuserid" but I'm not able to extract all of the output. I get the first line (which is the userid), but none of the groups. Can someone provide and example for how to do this? I can't help but think that this has been solved several times already. Below is the function-snippet from our trigger that has the core logic.
I have a very similar function that performs the command "aa groups" that works just fine. So I'm at a loss as to why this doesn't work.
Kind regards,
-Sean
function GetGroupsForUser(theuser)
{
var readResult = new Array();
var cmd = new Packages.com.mks.api.Command("aa","users");
cmd.addOption(new Packages.com.mks.api.Option("groups"));
cmd.addSelection(theuser);
var response = api.executeCmdAs(theuser, cmd);
if( response.getExitCode() == 0 )
{
if (response.getWorkItemListSize() != 0 )
{
var iter = response.getWorkItems()
while (iter.hasNext())
{
var workitem = iter.next()
readResult.push(workitem);
}
}
}
return readResult;
}

