I’d like to query the user profile service and get users only by a specific property – for example by Job Title. Is there any way to do this using the client object model?
I do NOT want to query all site users collection and then filter them in-memory. Anyway to query directly the UPS – even passing a caml?
Just wanted to confirm for anyone trying to fetch Country property in SharePoint online. This is NOT possible with the client object model.
If you are using on-prem SharePoint, then you might modify the UPS to return this property, but if you are using SharePoint Online, then there is NO way to do it but to leveraging on Windows Azure APIs – you will need to:
1. Leverage on the Graph API for Azure.
2. In VS, using C#, there is a special library – just look for Microsoft.Azure.ActiveDirectory.GraphClient in NuGet packages.
3. Register your component / App as Azure App Principle using the Get-MsolServicePrincipal and Add-MsolRoleMember Azure AD cmdlets.
Akanksha, this is how you query all user profiles, not just one by specific property.
Anyway, it is better to go off with an setup / configuration list at the moment which would deal with the mapping – less coding, more architecture 🙂
That’s just for one user. You still need to make a call to get a list of users like I suggested.Â
You can do this using Rest Api by this url:Â
http://<sitename>/_api/sp.userprofiles.peoplemanager/
From this you can get the data by parsing likeÂ
for eg. d.UserProfileProperties.key.
This way you can get all Properties of the user.
No, there is currently no option to get a list of profiles from UPS using client-side code. You will need to get a collection of users from a scope object such as SPWeb or SPSite first, and then you can retrieve the profile properties for that user.