I would like to pull a list of all users in a business group including those accounts who are members through an AD group. The query below works fine up to the 100 member limit. I can't figure out a way to get around it. I could use a quick loop if I could figure out how many results have been returned as an integer. Arghhh!! Any thoughts on how to do this?
function getUsersInGroup(tenant, adGroup, authenticationGroupService) {
var query = new vCACCAFEOdataQuery();
var myvCACCAFEPageOdataRequest = new vCACCAFEPageOdataRequest(1 , 1000 , query);
return authenticationGroupService.getUsersInGroup(tenant, adGroup, null, myvCACCAFEPageOdataRequest);
}
Hi,
Check if the following KB is applicable - https://kb.vmware.com/s/article/2149013
Running 7.3 now. My search results has 121 entries but I only get the first 100. I've tried, found the following:
Looping - Would work if I could enumerate exactly how many objects are returned on the page. This seems like the most logical but...
Filter - Doesn't seem to apply as I want everything returned.
pagination / page - Not sure how this could apply as I have found no examples.
Pagination queries should be relatively easy. In the code you provided, just wrap the second and the third line in a loop, then on each loop iteration increase the page number (the first argument to vCACCAFEPageOdataRequest() constructor) by 1, and exit the loop when the call to getUsersInGroup() returns no items.
Hello BillStreet00,
I had a similar problem, and I used direct API call to retrieve all users of a group, something like that I use currently :
var client = vcaccafeHost.createAuthenticationClient();
var groupService = client.getAuthenticationGroupService();
var groupPrincipalId = new vCACCAFEPrincipalId(groupName, vcaccafeHost.tenant);
var group = groupService.getGroupByPrincipalId(vcaccafeHost.tenant, groupPrincipalId);
var groupUrl = "/tenants/" + vcaccafeHost.tenant + "/groups/" + group.getFqdn() + "/users?expandGroups=true";
var limitByPage = 90; // DO NOT EXCEED 90, BECAUSE MAX SYSTEM VALUE IS 101 AND PAGE INDEX FUNCTIONALITY DOESN'T WORK ANYMORE !!!!!!!!!
var resourcesUrl = function(page) {
var queryUrl = "?limit="+ limitByPage + "&page=" + page;
if(query) {
queryUrl += "&" + query;
}
if(filter) {
queryUrl += "&$filter=" + filter;
}
if(orderBy) {
queryUrl += "&$orderby=" + orderBy; // &$orderby=dateCreated asc Bug if no order specified, resource appeared twice and some missing !!!
}
return queryUrl;
};
var idxPage = 1;
var requestUrl = groupUrl + resourcesUrl(idxPage);
var response = client.get(requestUrl);
var responseJson = response.getBodyAsJson();
And in the JSON, you can find some metadata about pages :
- responseJson.metadata.totalPages
- responseJson.links
You can loop with this information.
Unfortunately :
- sometimes the json response is bad formatted (That's failed !!!) and I use getBodyAsString, clean and JSON.parse() ...
- sometimes, with some API request url, you don't have metadata or links...So I just retry until I receive no results !
- if you don't add orderBy query parameter, you can have duplication and some users missing
- Do not try to use a limit over than 99, everything will failed
Emmanuel.