ユーザー プロファイルを取得する
最終更新日: 2010年1月27日
適用対象: SharePoint Server 2010
このコード例は、ユーザー プロファイル オブジェクト モデルを使用してユーザー プロファイル データを取得する方法を示しています。
このコード例を実行する前に、domainname、username、および電話番号 (nnnnnnnnnn) を実際の値に置き換えてください。さらに、Microsoft Visual Studio プロジェクトに次の参照を追加してください。
Microsoft.Office.Server
Microsoft.Office.Server.UseProfiles
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"))
{
SPServiceContext context =
SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
string sAccount = "domainname\\username";
UserProfile u = profileManager.GetUserProfile(sAccount);
//Updates values
u[PropertyConstants.HomePhone].Value = "nnnnnnnnnn";
u[PropertyConstants.CellPhone].Value = "nnnnnnnnnn";
//commits changes
u.Commit();
}
}
}
}
関連項目
タスク
[方法] Web サービスを使用してユーザーのプロファイル データを取得する