Query SharePoint user profile by custom property RRS feed

  • Question

  • I added a user defined property in SharePoint user profile service, and now I want to retrieve user profiles with specific value for that custom property.

    is it possible without using the IEnumerator returned by UserProfileManager.GetEnumerator()?

    I found several methods:




    Any of them is for my requirement? what's the difference between them?

    Friday, December 18, 2015 10:01 AM


All replies

  • Hi Yuming,

    UserProfileManager.Search and ResolveProfile methods can't search custom userprofile property. The methods can work with the searchable property.

    For more information:

    SharePoint UserProfile Search method demo:

    User Profile Search Method:

    The ProfileSearchManager.Search can combine and search different profile type. It supports Audience object.

    This method can search for the custom properties.

    More information:

    KeyWord Query to search user profile


    Best Regards

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact

    Monday, December 21, 2015 10:38 AM
  • I just tried UserProfileManager.Search, looks like it does not accept searchPattern like { “User”, “UserOne”} as described in the blog above.

    You can see in my screenshot that if I simply pass in a property value string, I get result. I won't if I pass in search pattern like {'xxx','x'}

    The following is the T-SQL I get with SQL prorfile when I use a search pattern

    exec dbo.proc_Profile_SearchUser @partitionID='0C37852B-34D0-418E-91C6-2AC25AF4BE5B',@correlationId='00000000-0000-0000-0000-000000000000',@Term1=N'{''test1'',''guyuming''}'the important table use in proc_Profile_SearchUser is Profile_SearchUserTermStats, however, I have not found out how it is maintained. But I think a simple approach to find out which properties are searchable is to input a unique value into a test profile entry, if that unique property value appears in the Profile_SearchUserTermStats table, that property are searchable:

    • Edited by GuYuming Tuesday, January 12, 2016 8:30 AM
    Tuesday, January 12, 2016 8:23 AM
  • my test shows that UserProfileManager.ResolveProfile does not recognize search pattern either. It also accept a property value parameter.

    But unlike search, resolve only match the property value in 3 hardcoded properties. If the @PropertyID2 parameter can take non-default value, it may match other properties. But in my simple test, these @PropertyIDx always take the default value.

    ALTER PROCEDURE [dbo].[proc_Profile_ResolveUser]
        @partitionID uniqueidentifier,
        @Term1 nvarchar(255),
        @PropertyID1 int = 3, -- Account Name
        @PropertyID2 int = 7, -- Preferred Name
        @PropertyID3 int = 17, -- UserName

    Tuesday, January 12, 2016 9:23 AM
  • I just found that the "test1" custom property I created is said to be searchable, but its property value does not appear in the Profile_SearchUserTermStats table and Profile_SearchUserTable table, and I cannot search by this custom property

    Tuesday, January 12, 2016 9:57 AM
  • found out at last, it is hardcoded in T-SQL function:

    ALTER FUNCTION [dbo].[fn_GetSearchablePropertyList]
        @partitionID uniqueidentifier,
        @correlationId uniqueidentifier = NULL
        RETURNS @Ret TABLE (PropertyID int, PropertyName nvarchar(250))
        INSERT INTO @Ret
        SELECT PropertyID, PropertyName from PropertyList
        WHERE IsSearchable = 1 AND DataType = 'nvarchar' AND PartitionID = @partitionID
        AND PropertyName IN (
        RETURN ;

    Tuesday, January 12, 2016 10:14 AM