sharepoint 中獲取用戶信息

SPList discList = web.Lists["YourDiscussion"];

foreach(SPListItem item in discList.Items)
// all replies
{
string formatedCreatedBy = (string)item["Author"]; // 格式是用 ;# 分分割 userid 和 userdisplayname 即如 1;#Xiaofeng Wang
int

userId = formatedCreatedBy.SubString(0, formatedCreatedBy.IndexOf(";#"));SPUser author = web.AllUsers.GetByID(userId);

0string loginName = author.LoginName;
// 用戶名

// 用戶頭像應該是存在 SSP 的 UserProfile 中的,下面的代碼,要求當前用戶具有管理 SSP UserProfile 的至少只讀權限,
// 可用 SPSecurity.RunWithElevatedPrivileges 此時要求該站點的 App Pool ID 具有以上權限
//SPSecurity.RunWithElevatedPrivilge(delegate() {});

 

UserProfileManager upMan = new UserProfileManager();

if (upMan.UserExists(loginName))
{
     
 UserProfile up = upMan.GetUserProfile(authorUser.LoginName);
    
  string picUrl = up[PropertyConstants.PictureUrl].Value.ToString();
// 照片 URL
 
}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章