Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

My user profiles have some custom properties. Now I need to get a list of all values that this custom property has on any user. This code return an error that "Column 'Division' does not exist. It may have been deleted by another user".

Is this the right approach? There is many users and possible many distinct values.

 SPListItemCollection userInformationList = SPContext.Current.Web.SiteUserInfoList.Items;
  var divisions= (from SPListItem userItem in userInformationList.Items where userItem["Division"] != null select userItem["Division"]); 
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Check the GetUserProfile from UserProfileManager. You get the whole object, should be the right spot to search for a list of all custom properties..

i'm working on an almost simliar webpart.. im trying to display only a couple of custom properties..

hope to help

http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.aspx

share|improve this answer
add comment

First of all never ever use LINQ in this way in SharePoint! You will retrieve the full user information list from the database when hitting the .Items property! Instead use a CAML query to "search" for the users using the SPQuery object.

I would recommend that you use the U2U CAML Query builder to build your query - using that tool you will get the correct columns and column name.

share|improve this answer
    
thanks for the input. I've installed it, but here my custom properties is not selectable in list. Is there any way I can provision theese custom properties to UserInformationList? –  Jorid Aug 3 '11 at 10:21
    
Are we talking about custom user profile properties (added in the User Profile Service) or is it custom columns to the user info list? If it's User Profile properties, then you can't do it this way - you need to look into search or similar. –  Wictor Wilen MCA MCM MVP Aug 3 '11 at 10:39
    
It's User Profile properties –  Jorid Aug 3 '11 at 10:51
    
could you point me in any direction? where can I start? –  Jorid Aug 3 '11 at 11:29
    
See Peters answer. Although it will invoke traversing all user profiles - which of course can take a looong time... You can also configure the property to use values from the Managed Metadata Store - then it's easy to get all unique values using just the MMS API's. –  Wictor Wilen MCA MCM MVP Aug 3 '11 at 13:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.