SharePoint User Profile Search

Posted by lucasstark on Stack Overflow See other posts from Stack Overflow or by lucasstark
Published on 2010-01-08T21:25:14Z Indexed on 2010/03/25 12:23 UTC
Read the original article Hit count: 451

Filed under:
|

Is there a way to search profiles in MOSS from the object model? I need to search for profiles that have a certain value set on their profile and then perform some action for them.

I need to write some c# code that can search the profiles database and return the matching profiles. Basically,

List of Profiles = Select Profiles From Profile Store Where Profile Property Value = SomeValue

I'm trying to avoid the following:

 private IEnumerable<UserProfile> SearchProfiles(string value) {
        ServerContext serverContext = ServerContext.GetContext(SPContext.Current.Site);
        UserProfileManager profileManager = new UserProfileManager(serverContext);
        foreach (UserProfile profile in profileManager) {
            if ((string)profile["MyProp"].Value == value) {
                yield return profile;
            }
        }
    }

© Stack Overflow or respective owner

Related posts about sharepoint2007

Related posts about profiles