対象ユーザーのメンバを決定する

最終更新日: 2010年1月27日

適用対象: SharePoint Server 2010

この例は、対象ユーザーのメンバを決定する方法を示しています。

この例を使用する前に、servername およびその他のプレースホルダの文字列を、実際の値に置き換えてください。また、Microsoft Visual Studio プロジェクトに以下の参照を追加します。

  • Microsoft.Office.Server

  • Microsoft.Office.Server.UserProfiles

  • Microsoft.SharePoint

  • System.Web

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server.Audience;
using Microsoft.SharePoint;
using Microsoft.Office.Server;
using System.Web;
using System.Collections;

namespace AudienceConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (SPSite site = new SPSite("https://servername"))
                {
                    SPServiceContext context = SPServiceContext.GetContext(site);
                    AudienceManager AudMgr = new AudienceManager(context);
                    try
                    {
                        ArrayList memarray = AudMgr.Audiences["Customer Connection Team"].GetMembership();

                        foreach (UserInfo o in memarray)
                        {
                            Console.WriteLine(o.NTName);
                        }
                        Console.Read();
                    }
                    catch (AudienceException e)
                    {
                        //Your exception handling code here
                    }
                }


            }


            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Read();
            }

        }
    }

}

関連項目

その他の技術情報

対象ユーザーを使用してコンテンツを設定する