I ended up implementing the following solution using the REST endpoints.
var userName = "adminUser";
var password = "adminPassword";
string tokenURL = portalURL + "/sharing/rest/generateToken";
var credentialTask = AuthenticationManager.Current.GenerateCredentialAsync(new Uri(tokenURL), userName, password);
credentialTask.Wait();
TokenCredential cred = credentialTask.Result;
var client = new HttpClient();
int start = 1;
int number = 10;
while (start != -1)
{
string url = string.Format("{0}/sharing/rest/portals/self/users/search?start={1}&num={2}&f=json&token={3}", portalURL, start, number, cred.Token);
var request = new HttpRequestMessage(HttpMethod.Post, url);
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var jsonResponse = response.Content.ReadAsStringAsync().Result;
Root? root = JsonConvert.DeserializeObject<Root?>(jsonResponse);
foreach (Result user in root.Results)
{
Console.WriteLine(user.FullName);
}
start = root.NextStart;
}
Here are my Root and Result classes to store the json results from the call.
public class Result
{
public string UserName { get; set; }
public object UDN { get; set; }
public string ID { get; set; }
public string FullName { get; set; }
public List<string> Categories { get; set; }
public string EmailStatus { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public object PreferredView { get; set; }
public object Description { get; set; }
public string Email { get; set; }
public string UserType { get; set; }
public object IDPUsername { get; set; }
public object FavGroupId { get; set; }
public object LastLogin { get; set; }
public bool MFAEnabled { get; set; }
public bool ValidateUserProfile { get; set; }
public int StorageUsage { get; set; }
public int StorageQuota { get; set; }
public string OrgId { get; set; }
public string Role { get; set; }
public string Level { get; set; }
public string UserLicenseTypeId { get; set; }
public bool Disabled { get; set; }
public List<object> Tags { get; set; }
public string Culture { get; set; }
public object CultureFormat { get; set; }
public object Region { get; set; }
public string Units { get; set; }
public object Thumbnail { get; set; }
public string Access { get; set; }
public object Created { get; set; }
public object Modified { get; set; }
public string Provider { get; set; }
public List<object> Groups { get; set; }
}
public class Root
{
public int Total { get; set; }
public int Start { get; set; }
public int Num { get; set; }
public int NextStart { get; set; }
public List<Result> Results { get; set; }
}