ユーザー プロファイル プロパティのプライバシー ポリシーを設定する
最終更新日: 2010年3月23日
適用対象: SharePoint Server 2010
Microsoft SharePoint Server 2010 では、ユーザー プロファイル プロパティ、メンバーシップ、仕事仲間などにプライバシー ポリシーを設定して、個人情報を表示および編集できるユーザーを制限することができます。
Default Privacy ポリシーでは、プロパティ、ユーザーの [マイ ドキュメント]、および他の [個人用サイト] のコンテンツの表示が以下のように制限されます。
[プライベート] : [自分のみ]
[マネージャ] : [自分と自分のマネージャ]
[自分の業務グループ] : [組織]
[自分の仕事仲間] : [連絡先]
[公開] : [すべてのユーザー]
Privacy Policy には、プロパティに対する値の指定が必須、無効、任意のいずれであるかを指定します。Privacy Policy は、ユーザー プロファイル プロパティにのみ適用できます。
以下のコード例は、プロパティのプライバシーを設定する方法を示しています。このコード例を実行する前に、servername と Hobbies を実際の値に置き換えます。また、参照を 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.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);
ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
ProfileSubtypeProperty p = pspm.GetPropertyByName("Hobbies");
p.DefaultPrivacy = Privacy.Manager;
p.PrivacyPolicy = PrivacyPolicy.OptIn;
p.Commit();
}
}
}
}