2008-10-22 18 views

回答

6

我花了下午的時間在這方面做了工作,並且已經完成了。

添加以下using語句引用Microsoft.Office.Server.dll和Microsoft.SharePoint.dll的

using Microsoft.SharePoint; 
using Microsoft.Office.Server; 
using Microsoft.Office.Server.UserProfiles; 

然後通過做訪問用戶配置文件後:

ServerContext sc = ServerContext.Current; 
UserProfileManager upm = new UserProfileManager(sc); 
UserProfile up = upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName); 

然後你就可以得到MySite的網站收集ID(SPSite.ID):

upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName).ID 

或t他通過以下站點ID(SPWeb.ID):

upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName).PersonalSite.RootWeb.ID 

顯而易見,不是真的!

+0

這比我的想法好得多:) – AdamBT 2008-10-22 15:01:28