سؤال

Is there any way in SharePoint 2010 to get the Distinct values of a property across all users? For example, I want a list of all Departments in the Profile Store.

In SQL I can do

SELECT DISTINCT(PropertyVal) FROM [ProfileDB].[dbo].[UserProfileValue]
WHERE PropertyID = 14

but accessing the SQL Database is a big no-no of course, so I wonder if there is something in the object model?

Note that accessing the User Information List on an SPSite is not good enough, as only a fraction of all users is in that list. I want to get it directly from the Profile Store.

I do not want to loop through UserProfileManager because a) it's sloooow and b) requires Elevated Permissions that even SPSecurity.RunWithElevatedPermissions doesn't provide.

Before I write a timer job that does that, is there some other way to do that?

هل كانت مفيدة؟

المحلول 2

Ended up querying Active Directory directly since the SharePoint 2010 User Profile Store doesn't have a way to be queried efficiently.

نصائح أخرى

As far as I am aware this can only be done with choice fields. For something like the department you would likely have to iterate through the profiles.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top