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

I can see that UserProfileManager class does have a method GetManager() to pull manager from users profile but I don't see any thing which returns list of all users currently reporting to particular user. I am wondering if there is any workaround.

SPSite site;
SPWeb web;
SPServiceContext serviceContext;
UserProfileManager profiles;
UserProfile profile;

try
{
  using (site = new SPSite(SPContext.Current.Web.Url))
  {
    using (web = site.OpenWeb())
    {
      serviceContext = SPServiceContext.GetContext(site);
      profiles = new UserProfileManager(serviceContext);

      //Getting the profile of logged in user.
     profile = profiles.GetUserProfile(web.CurrentUser.LoginName);

    //Getting profile of the manager of the logged in user.
    profile = profile.GetManager();
    }
  }
}
catch { }
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You do indeed have methods for getting manager, peers and direct reports:

        // Check whether the user profile and the manager user profile exist, and that they are not                  
        // the same user.            
        if (userProfileManager.UserExists(loginName))
        {
            // Retrieve the user profile.                
            UserProfile userProfile = userProfileManager.GetUserProfile(loginName);  

            // Get the user's multiple levels of managers, peers, and direct reports.                 
            managers = new List<UserProfile>(userProfile.GetManagers());                
            peers = new List<UserProfile>(userProfile.GetPeers());                
            directReports = new List<UserProfile>(userProfile.GetDirectReports());

}

Works in 2007, should be same in 2010: http://msdn.microsoft.com/en-us/library/cc973103(v=office.12).aspx

share|improve this answer
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.