[方法] 複数の値を持つプロパティに複数の値を設定する

Microsoft Office SharePoint Server 2007 は複数の値を持つプロパティをサポートするため、UserProfile オブジェクトにある this[] 演算子は、UserProfileValueCollection という ArrayList を返します。次のコード例は、複数の値を持つプロパティに複数の値を追加する方法を示しています。PublishedPapers プロパティを作成する方法については、「[方法] 複数値プロパティを作成する」を参照してください。

コード例を実行する前に、servername、domainname、および username を実際の値に置き換えてください。また、Microsoft Visual Studio プロジェクトで以下への参照を追加してください。

  • Microsoft.Office.Server

  • Microsoft.SharePoint

  • System.Web

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

namespace UserProfilesApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://servername"))
            {
                ServerContext context =
                    ServerContext.GetContext(site);
                UserProfileManager profileManager = new
                    UserProfileManager(context);
                UserProfile profile =
                  profileManager.GetUserProfile("domainname\\username");
                    profile["PublishedPapers"].Add((Object)"a@b.com");
                    profile["PublishedPapers"].Add((Object)"c@d.com");
                    profile.Commit();              }
        }
    }
}

See Also

タスク

[方法] 複数値プロパティを作成する

[方法] 複数値プロパティを入力するための既定の区切り文字を変更する

[方法] 選択肢リストがあるプロパティを作成する

[方法] ユーザー プロファイル プロパティのプライバシー ポリシーを設定する