In one of my previous posts (see Create custom AD attribute and map it to Sharepoint user profile property) I showed how you can extent your AD schema with custom attributes and how to add them into User profiles properties. Here I want to show how to use these custom attributes in standard People search and how to customize People search results for displaying them.
Once you mapped attributes, customization of People search results is fairly easy. First of all you need to create Managed properties in Search service application and map them to properties of user profiles (see also my post AD attributes used in standard configuration of People search in Sharepoint where I showed what attributes are used in standard configuration of People search and their mappings). In order to do this go to Central Administration > Manage service applications > Search service applications > Metadata properties and create new Managed property for your custom attributes. E.g. if you follow by the same example which I used in the post mentioned above, you can create new Managed property with name “BusinessUnit” and add map to the Crawled property (User profile property) “People:BusinessUnit” (you can filter crawled properties by categories). After that perform full crawl.
Now you can go to your site and search for people using custom BusinessUnit property. E.g. if you need to find people which belongs to Russian business unit you can specify BusinessUnit:Russia in the search box – search results will contain people for specified unit.
The remaining problem is that business units themselves are not displayed on the search result page. In order to display them we need to customize OTB CoreResultsWebPart on People search page in the Search center site. Go to People search page and edit it, then choose Edit web part for Core results web part. Here uncheck “Use Location Visualization” checkbox and add the following columns into “Fetched Properties” textbox:
Name attribute should contains name of Managed property which we created earlier. After this you need to modify XSLT template – add custom property into template. Click XSLT editor in web part properties and make the following changes:
find the following line:
and insert this code after it:
After this search for the following statement:
and add similar code after it:
Save changes and try to search for people which contains some value in Business Unit property. Search result page will now display value of this custom property near each user.