Опитвам се да създам част от код, който ще попълни списъкен обект с всички потребители в рамките на услугата за потребителски профил на SharePoint.
Добавих препратки за Microsoft.SharePoint, Microsoft.Office.Server.UserProfiles и имам следния блок код:
using Microsoft.SharePoint;
using Microsoft.Office.Server.UserProfiles;
using System.Web;
namespace code.runner.intranet.Dal
{
public class SPUsersDal : BaseDal
{
public List<SPUsersEntity> FetchItems(string siteName)
{
try
{
PostEvent("Attempting to load users from: " + siteName, BaseExceptionEventArgs.ExceptionLevel.Debug);
using (var site = new SPSite(siteName))
{
using (var web = site.OpenWeb())
{
PostEvent("Successfully opened: " + web.Url, BaseExceptionEventArgs.ExceptionLevel.Debug);
var serviceContext = SPServiceContext.GetContext(site);
var userProfileManager = new UserProfileManager(serviceContext);
foreach (UserProfile userProfile in userProfileManager)
{
// ...your code
}
}
Въпреки това следните редове:
var serviceContext = SPServiceContext.GetContext(site);
var userProfileManager = new UserProfileManager(serviceContext);
Има грешка със съобщението:
Типът "HttpContext" е дефиниран в сборка, която не е препратена. Трябва да добавите препратка към сборката System.Web"
Тъй като вече имам препратка към System.Web, не съм сигурен защо получавам това. Също така не можах да накарам примера на Microsoft да работи (виж тук: https://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofile.aspx), получавайки същата грешка на същите обекти.
какво ми липсва