如何使用UserProfileManager获取对特定用户报告的所有用户列表?
-
09-12-2019 - |
题
我可以看到userprofilemanager类确实有一个方法getManager()来从用户配置文件配置,但我没有看到任何返回当前向特定用户报告的用户列表的任何东西。我想知道是否有任何解决方法。
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 { }
. 解决方案
您确实拥有获得经理,对等体和直接报告的方法:
// 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());
.
}
在2007年工作,在2010年应该是相同的: http://msdn.microsoft.com/en-us/library/cc973103(v= Office.12).aspx