PropertyMap 类
表示定义属性在用户配置文件和导入数据源之间的映射的属性映射 — Microsoft Active Directory 目录服务。
继承层次结构
System.Object
Microsoft.Office.Server.UserProfiles.PropertyMap
命名空间: Microsoft.Office.Server.UserProfiles
程序集: Microsoft.Office.Server.UserProfiles(位于 Microsoft.Office.Server.UserProfiles.dll 中)
语法
声明
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class PropertyMap
用法
Dim instance As PropertyMap
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class PropertyMap
备注
允许只是一对一的关系。如果尝试将多个用户配置文件属性映射到一个 Active Directory 属性,或将一个用户配置文件属性映射到多个活动目录属性,将引发UPDuplicateEntryException 。
示例
下面的代码示例显示PropertyMap类的使用。
static public void PropertyTypeAndMappingSample()
{
using (SPSite site = new SPSite("site url"))
{
SPServiceContext context = SPServiceContext.GetContext(site);
//Initialize user profile config manager object.
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
ConnectionManager cm = upcm.ConnectionManager;
//Sample to get a property type.
PropertyDataTypeCollection pdtc = upcm.GetPropertyDataTypes();
PropertyDataType ptype = null;
foreach (PropertyDataType datatype in pdtc)
{
if (datatype.Name.Equals("string"))
{
ptype = datatype;
break;
}
}
//Sample to create a new custom property.
ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
CorePropertyManager cpm = ppm.GetCoreProperties();
ProfileTypePropertyManager ptpm = ppm.GetProfileTypeProperties(ProfileType.User);
ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
CoreProperty coreProp = cpm.Create(false);
coreProp.Name = "division";
coreProp.DisplayName = "my custom division";
coreProp.Type = ptype.Name;
coreProp.Length = ptype.MaxCharCount;
coreProp.Commit();
ProfileTypeProperty profileTypeProp = ptpm.Create(coreProp);
profileTypeProp.IsVisibleOnEditor = true;
profileTypeProp.IsVisibleOnViewer = true;
profileTypeProp.Commit();
ProfileSubtypeProperty profileSubTypeProp = pspm.Create(profileTypeProp);
profileSubTypeProp.DefaultPrivacy = Privacy.Private;
profileSubTypeProp.IsUserEditable = true;
profileSubTypeProp.Commit();
pspm.SetDisplayOrderByPropertyName(profileSubTypeProp.Name, 1);
pspm.CommitDisplayOrder();
//Edit property sample.
CoreProperty ptitle = cpm.GetPropertyByName(PropertyConstants.Title);
// Or get property by URI.
ptitle = cpm.GetPropertyByURI(Property.URI_Title);
ptitle.DisplayName = "Designation";
ptitle.Commit();
//Property map sample.
string connectionName = "Test Connection";
Connection connection = cm[connectionName];
PropertyMapCollection pmc = connection.PropertyMapping;
pmc.AddNewMapping(ProfileType.User, profileSubTypeProp.Name, "division");
//Remove property sample.
cpm.RemovePropertyByName("division");
ptpm.RemovePropertyByName("division");
pspm.RemovePropertyByName("division");
}
}
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。