Tôi muốn người dùng thông thường có thể truy cập "Danh sách thông tin người dùng" trong trang web gốc Mysite. Tôi đang sử dụng phương pháp "RunWithElevatedPrivileges". Vẫn đang ném truy cập bị từ chối lỗi. ví dụ: tuyển tập trang gốc của tôi cho mysite là "http://network.test.com". người dùng muốn đánh giá danh sách userinformation bộ sưu tập trang web này. Làm thế nào ông có thể truy cập đó?Truy cập bị từ chối khi sử dụng RunWithElevatedPrivileges?
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(SPContext.Current.Web.Site.ID))
{
ServerContext sc = ServerContext.Current;
UserProfileManager upm = new UserProfileManager(sc);
UserProfile up = null;
//get current user's profile (visitor)
if (upm.UserExists(SPContext.Current.Web.CurrentUser.LoginName))
{
up =upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);
SPWeb web = SPContext.Current.Web;
SPList userInformationList = web.Lists["User Information List"];
bạn có chạy mã trong máy chủ chứa SharePoint không? –