Property-Klasse
Die Definition für eine Benutzerprofileigenschaft darstellt.
Vererbungshierarchie
System.Object
Microsoft.Office.Server.UserProfiles.Property
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 Property _
Implements IPrivacyPolicyItem
'Usage
Dim instance As [Property]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class Property : IPrivacyPolicyItem
Hinweise
Es gibt zwei Arten von Benutzerprofileigenschaften:
Reguläre Definiert den Datentyp der Eigenschaft und den entsprechenden Benutzer Profil erfasst.
Abschnitt Eigenschaft, die als Trennzeichen für die Benutzeroberfläche zum Zweck dient.
In Microsoft SharePoint Server 2010delegiert diese Art die meisten der Methoden CoreProperty, ProfileTypePropertyund ProfileSubtypeProperty. Ausnahmen werden von diesen Klassen ausgelöst.
Beispiele
Das folgende Codebeispiel veranschaulicht die Verwendung der Property -Klasse.
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");
}
}
Threadsicherheit
Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.