Thursday 15 September 2011

Get user colleagues with Sharepoint 2010 object model


Getting colleagues for the current user from user's user profile is much easier.

Lets look at an example -

ServerContext siteContext = ServerContext.GetContext(siteCollection);

UserProfileManager oUserProfileManager = new UserProfileManager(siteContext);

UserProfile oUserProfile = oUserProfileManager.GetUserProfile(_spUser.LoginName);

foreach (Colleague colleague in oUserProfile.Colleagues.GetItems())
{
//Get colleagues
}

Ads by Google

No comments:

Post a Comment