Come posso ottenere elenco di tutti gli utenti che segnalano a un determinato utente utilizzando UserProfileManager?

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/46011

Domanda

Posso vedere che UserProfileManager Class ha un metodo GetManager () per estrarre Gestore dal profilo degli utenti ma non vedo alcuna cosa che restituisce l'elenco di tutti gli utenti che attualmente riportano a un determinato utente.Mi chiedo se c'è qualche soluzione.

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 { }
.

È stato utile?

Soluzione

Hai effettivamente metodi per ottenere gestore, peer e report diretti:

        // 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());
.

}

Lavori nel 2007, dovrebbe essere uguale nel 2010: http://msdn.microsoft.com/en-us/library/cc973103 (v= office.12) .aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top