01-06-2016 08:07 AM - edited 03-10-2019 11:22 PM
Hi,
I'm using the REST API default call to query the user list but it only bring me back 20 records.
Looking for a solution I discover a parameter to put in the call URI but it has a limit to 100 that doesn't solve my problem.
Considering I don't know how many users are in the guest database how can I make a query to export all users from guest database?
::: default query
curl -k -X GET -H 'ACCEPT: application/vnd.com.cisco.ise.idecisco.ise.identity.guestuser.2.0+xml' https://<user>:<pwd>@<hostname>:9060/ers/config/guestuser
::: query with size parameter
curl -o <outputfile> -k -X GET -H 'ACCEPT: application/vnd.com.cisco.ise.idecisco.ise.identity.guestuser.2.0+xml' https://<user>:<pwd>@<hostname>:9060/ers/config/guestuser?size=100&page=1&sortdsc=name
Kind Regards
01-06-2016 07:17 PM
Ise returns info about number of pages in your paged request, use that info to loop through all the pages.
01-06-2016 07:25 PM
I have written a few thing in PHP using many of the different ISE API's, this PHP function is used to get all endpoints with paging supported, it could be modified to do guest user list instead.
function get_all_endpoints()
// Retrieve all mac entries and the corresponding mac address and identity group id
{
$i = 0;
$x = 0;
$pagesize = 100;
$pagenum = 1;
$total = 1;
$fetched = 0;
while ($fetched < $total)
{
exec("curl -ss -k -X GET -H 'ACCEPT: application/vnd.com.cisco.ise.identity.endpoint.1.0+xml' \"https://" . $GLOBALS["iserestapiuser"] . ":" . $GLOBALS["iserestapipass"] . "@" . $GLOBALS["iserestapihost"] . ":9060/ers/config/endpoint?size=" . $pagesize . "&page=" . $pagenum . "\"",$out);
$xml[$pagenum] = new SimpleXMLElement(implode(" ",$out));
$total = $xml[$pagenum]->attributes()->total;
echo "Total endpoints: " . $xml[$pagenum]->attributes()->total . "\n\r";
echo "pages: " . ($total/$pagesize) . "Page=" . $pagenum . "\n\r";
foreach ($xml[$pagenum]->resources->resource as $entry) {
$link = $entry->link->attributes()->href;
$ret[$i]["endpointid"] = (string) $entry->attributes()->id;
//echo var_dump($entry);
exec("curl -ss -k -X GET -H 'ACCEPT: application/vnd.com.cisco.ise.identity.endpoint.1.0+xml' https://" . $GLOBALS["iserestapiuser"] . ":" . $GLOBALS["iserestapipass"] . "@" . $GLOBALS["iserestapihost"] . ":9060/ers/config/endpoint/" . $ret[$i]["endpointid"],$out2);
$xmlendpoint[$pagenum] = new SimpleXMLElement(implode(" ",$out2));
$ret[$i]["mac"] = (string) $xmlendpoint[$pagenum]->mac;
$ret[$i]["endpointgroupid"] = (string) $xmlendpoint[$pagenum]->groupId;
$ret[$i]["description"] = (string) $xmlendpoint[$pagenum]->attributes()->description;
$ret[$i]["portaluser"] = (string) $xmlendpoint[$pagenum]->portalUser;
$ret[$i]["identitystore"] = (string) $xmlendpoint[$pagenum]->identityStore;
$ret[$i]["identitystoreid"] = (string) $xmlendpoint[$pagenum]->identityStoreId;
$ret[$i]["profileid"] = (string) $xmlendpoint[$pagenum]->profileId;
$ret[$i]["staticgroup"] = (string) $xmlendpoint[$pagenum]->staticGroupAssignment;
$ret[$i]["staticprofile"] = (string) $xmlendpoint[$pagenum]->staticProfileAssignment;
$i+=1;
$x+=1;
$out2 = "";
}
$out = "";
//echo "Antal entries hentet i loop: " . $x . "Side: " . $pagenum . "\n\r";
$fetched = $fetched + $x;
//echo "Antal hentet totalt: " . $fetched . "\n\r";
$pagenum +=1;
$x = 0;
}
//echo var_dump($ret);
return $ret;
}
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide