Share via


[方法] ユーザー プロファイル プロパティを取得する

このコード例では、ユーザー プロファイル オブジェクト モデルを使用して、サーバー上に存在するユーザー プロファイル プロパティを表示します。コード例を実行する前に、servername を実際の値に置き換えてください。また、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 m_mngr = new UserProfileManager(context);

                   //Get the properties
                   PropertyCollection props = m_mngr.Properties;
                   foreach (Property prop in props)
                   {
                       Console.WriteLine(prop.Name);
                   }

               }
            }

        }
    }

See Also

タスク

[方法] ユーザー プロファイルを取得する

[方法] 2 つのユーザー プロファイル間の共通点を取得する

[方法] 変更ログを使用してユーザー プロファイルの最新の変更を取得する