Edit: Ignore this response. As Fabien pointed out I did not see that this question was for Jira Server and this response is for Jira Cloud.
Cloud-only: In the response to the rest/api/2/user/search there should be a parameter for each account called “accountType”. Portal-only accounts will have that value set to “customer”, while Atlassian accounts will be “atlassian”. So you should be able to filter by that value once you have the list.