locked
Get all user profiles by REST api RRS feed

  • Question

  • Hi,

    I have created user profile service application successfully by central administration UI. According to my requirement I have to get and save all users info to list in my appplication. After started synchronization It was showing 1200+ number of user profiles but when i browse the below rest api url it showing 89(rowCount) only. Can anyone suggest why i'm unable to get all user profiles?

    http://abcd/_api/search/query?querytext='AccountName:XYZ\*'&selectproperties='PreferredName,Department'&SourceId='b09a7990-05ea-4af9-81ef-edfab16c4e31'&rowlimit='500'   

    or

    http://abcd/_api/search/query?querytext='AccountName:*'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&selectproperties='AccountName'&rowlimit='500'

    When I try below , its showing the accounts that who have permissions to access my site.

    http://abcd/_api/Web/SiteUsers

    Wednesday, November 4, 2015 12:45 PM

Answers

  • Hi Again Flying Hope

    there is a way 

    you can get benefit from 2 methods in the UserProfileService 
    1) GetUserProfileCount 
    2) GetUserProfileByIndex

    and use the below code

    UserProfileService service = new UserProfileService();
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    int countProfile = (int)service.GetUserProfileCount();
    for (int i = 0; i < countProfile; i++)
    {
    //Write your code to Import to the list
    Response.Write(service.GetUserProfileByIndex(i).UserProfile[1].Values[0].Value);
    }
    Thursday, November 5, 2015 4:59 AM