Getting SharePoint User Profile Peers

Using SharePoint User Profiles is an exceedingly influential option when working with additional SharePoint user data. One impressive method is the GetPeers() method which as the name implies, allows you to query down into user peers from a profile object. The GetPeers method returns an array of User Profile objects, which you can later iterate through in order to perform whatever operations you desire. For my particular example, I was writing hierarchal user data, so coupled the GetPeers() method with the GetManager() method to build visual representation of organizational hierarchy.


public List GetUserProfilePeerData(string url)
SPSecurity.CatchAccessDeniedException = false;
List peerProfiles = new List();
using (SPSite site = new SPSite(url))
UserProfileManager manager = new UserProfileManager(ServerContext.GetContext(site));
foreach (UserProfile profile in manager)
foreach (UserProfile peerProfile in profile.GetPeers())
return peerProfiles;


3 thoughts on “Getting SharePoint User Profile Peers”

  1. I am trying to do something along the same line. I am trying to write an Custom Organizational Hierarchy webpart of my own. I was wondering if you could pass along some advice on how to go about doing this


  2. How do you get a list of all users.I am trying to populate a dropdown of users with an action based on selection.


Leave a Reply

Your email address will not be published. Required fields are marked *