1

Visual Studio 2010 と C# を使用して、SharePoint 2010 サイト内のすべてのグループを列挙したいと考えています。絶対に必要でない限り、展開する必要があるものは作成したくありません。基本的に、SharePoint インスタンスに接続して、何も展開せずにグループやその他のオブジェクトを調べる方法はありますか?

PowerShell スクリプトで応答しないでください。Visual Studio と C# を使用してこれを行いたいと考えています。

ありがとう、
ダグ

4

1 に答える 1

1

SharePoint 2010 クライアント オブジェクト モデル (2010 & 2013) を使用すると、次のように記述できます。

static void Main(string[] args)
{
    var ctx = new ClientContext("http://server");
    ctx.Credentials = new System.Net.NetworkCredential("username", "password", "domain");

    ctx.Load(ctx.Web.SiteGroups);
    ctx.ExecuteQuery();

    foreach (Group g in ctx.Web.SiteGroups)
    {
        Console.WriteLine(g.LoginName);
    }
}
于 2013-03-20T03:51:41.537 に答える