質問

私のサイトコレクションのサイトはカスタムプロパティを使用して、サイトの "Type"を決定しています。e.g.

web.Properties["SiteCategory"] = "SomeCategory1";
.

カスタムプロパティを持つ私のサイトコレクションのすべてのサイトを表示するためのWebパーツの作成を計画しています。

これが私が計画していることの範囲:

SPSite site = SPContext.Current.Site;
foreach (SPWeb web in site.AllWebs)
{
  if (web.Properties["SiteCategory"] == "SomeCategory1") {
     /* Insert code to display the current site URL on the web part */
  }
}
.

現在のユーザーにセキュリティがトリミングされますか?それとも、サイトコレクションのすべてのサイトを表示するだけですか?セキュリティトリミングされていることを確認する必要がありますか?

また、性能上、これは実行可能なオプションですか?これを行う方法がいくつかある場合は、すべての耳です。

役に立ちましたか?

解決

次のコードを使用してください。

using(SPSite site = new SPSite("http://example/site/"))
{
    using (SPWeb web = site.OpenWeb())
    {
        SPWebCollection webCollection = web.GetSubwebsForCurrentUser();

            foreach (SPWeb web in webCollection)
             {
                if (web.Properties["SiteCategory"] == "SomeCategory1")
                    {}
             }
    }
}
.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top