2008-10-22 74 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