PropertyMap Class
Represents a property mapping that defines property mapping between the user profile and the import data source—Microsoft Active Directory directory service.
Inheritance Hierarchy
System.Object
Microsoft.Office.Server.UserProfiles.PropertyMap
Namespace: Microsoft.Office.Server.UserProfiles
Assembly: Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)
Syntax
'Declaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class PropertyMap
'Usage
Dim instance As PropertyMap
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class PropertyMap
Remarks
Only a one-on-one relationship is allowed. If there is an attempt to map more than one user profile property to one Active Directory property, or map one user profile property to more than one Active Directory property, an UPDuplicateEntryException is thrown.
Examples
The following code example shows the use of the PropertyMap class.
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");
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.