如何在 SharePoint 2013 中获取大量用户的个人资料

How to get a bulk of user's profiles in sharepoint 2013

我需要获取一份用户列表,其中包含他们的电子邮件地址、个人资料图片以及电话号码(如果可能的话)。

最好的选择是将其作为 Lists.GetListItemChangesSinceToken 请求的一部分或紧随其后的带有帐户名/电子邮件列表的请求。

我试过的:

感谢您的帮助。

看起来您在 Web 服务中找到了答案,但这里有一个替代方法(根据先前的项目在记事本中快速组合,因此可能需要一些改进,但它应该能为您提供总体思路):

var siteName = "";

using (var site = new SPSite(siteName))
{
    using (var web = site.OpenWeb())
    {
        var serviceContext = SPServiceContext.GetContext(site);
        var userProfileManager = new UserProfileManager(serviceContext);

        var profiles = new List<SPUsersEntity>();

        foreach (UserProfile profile in userProfileManager)
        {
                            profiles.Add(LoadItems( profile.DisplayName,
                                                    profile.AccountName,
                                                    Convert.ToString(currentProfile[PropertyConstants.Title].Value),
                                                    Convert.ToString(currentProfile[PropertyConstants.Department].Value),
                                                    Convert.ToString(currentProfile[PropertyConstants.PictureUrl].Value),
                                                    Convert.ToString(currentProfile[PropertyConstants.Manager].Value),
                                                    Convert.ToString(currentProfile[PropertyConstants.SPSDepartment].Value),
                                                    Convert.ToString(currentProfile[PropertyConstants.WorkEmail].Value) ,
                                                    Convert.ToString(currentProfile[PropertyConstants.WorkPhone].Value)));
    }
    }
}

public SPUsersEntity LoadItems(string name, string username, string title, string department, string pictureURL, string manager, string team, string email, string phone)
{
    var usersEntity = new SPUsersEntity
    {
        Name = name ,
        Username = username ,
        Title = title ,
        Department = department ,
        Picture = pictureURL ,
        Manager = manager ,
        Team = team ,
        Email = email ,
        WorkPhone = phone
    };

    return usersEntity;
}

public class SPUsersEntity
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string Username { get; set; }
    public string Manager { get; set; }
    public string Picture { get; set; }
    public string WorkPhone { get; set; }
    public DateTime HireDate { get; set; }
    public DateTime Birthday { get; set; }
    public string Title { get; set; }
    public string Department { get; set; }
    public string Team { get; set; }
    public string Email { get; set; }

}

好的,所以我尝试了很多选项,但完全错过了正确的选项:

_api/search/query?
sourceid='b09a7990-05ea-4af9-81ef-edfab16c4e31'&
querytext='ac‌​‌​countname:i:0#.f|membership|admin@company.com accountname:i:0#.f|membership|admin2@company.com'