PropertyMapCollection PropertyMapCollection PropertyMapCollection Class

Definition

Represents a collection of PropertyMap objects.

public ref class PropertyMapCollection
public class PropertyMapCollection
Public Class PropertyMapCollection
Inheritance
PropertyMapCollectionPropertyMapCollectionPropertyMapCollection

Examples

<p>The following code example shows the use of the <xref data-throw-if-not-resolved="true" uid="Microsoft.Office.Server.UserProfiles.PropertyMapCollection"></xref> class.</p>
<pre><code>static public void PropertyTypeAndMappingSample()

{

using (SPSite site = new SPSite("<span class="placeholder">site url</span>")) { 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"); } }

Remarks

This class stores all property mappings for the data source.

Properties

Connection Connection Connection
Count Count Count

Gets the number of user profile property maps for this collection.

Item[ProfileTypeProperty] Item[ProfileTypeProperty] Item[ProfileTypeProperty]
Item[String] Item[String] Item[String]

Gets the property map in the collection.

Methods

Add(String, ProfileTypeProperty, Boolean, Boolean) Add(String, ProfileTypeProperty, Boolean, Boolean) Add(String, ProfileTypeProperty, Boolean, Boolean)
Add(String, ProfileTypeProperty, Boolean, Boolean, String) Add(String, ProfileTypeProperty, Boolean, Boolean, String) Add(String, ProfileTypeProperty, Boolean, Boolean, String)
Add(String, ProfileType, String, Boolean, Boolean, String) Add(String, ProfileType, String, Boolean, Boolean, String) Add(String, ProfileType, String, Boolean, Boolean, String)
AddNewExportMapping(ProfileType, String, String) AddNewExportMapping(ProfileType, String, String) AddNewExportMapping(ProfileType, String, String)
AddNewMapping(ProfileType, String, String) AddNewMapping(ProfileType, String, String) AddNewMapping(ProfileType, String, String)
GetEnumerator() GetEnumerator() GetEnumerator()

Gets the enumerator for the PropertyMap objects.

RemoveAllExportMappingsForAttribute(String) RemoveAllExportMappingsForAttribute(String) RemoveAllExportMappingsForAttribute(String)

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to