3

C# で記述された Sharepoint WebPart では、現在のユーザーの MySite の ID を調べるか、現在のサイトがユーザーの MySite であるかどうかを確認する必要があります。

アイデア?

4

1 に答える 1

6

私は午後にこれに取り組み、解決しました。

Microsoft.Office.Server.dll および Microsoft.Sharepoint.dll を参照した後に、次の using ステートメントを追加します。

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

または、次の方法でサイト ID (SPWeb.ID) を取得します。

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

明らかに、そうではありません!

于 2008-10-22T14:59:56.710 に答える