UserProfile.Item property

Gets the value of the specified property.

Namespace:  Microsoft.Office.Server.UserProfiles
Assembly:  Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

public UserProfileValueCollection this[
	string strPropName
] { get; }

Parameters

strPropName
Type: System.String

The name of the property.

Property value

Type: Microsoft.Office.Server.UserProfiles.UserProfileValueCollection
The value of the specified property.

The Item property returns the value in the data type specified in the profile property schema PropertyCollection. When setting a property value, it is expected to be either the correct data type or a string that can be parsed to the correct data type. When passing a string, all properties must be formatted by using the portal site's culture settings except for dates, which must be formatted by using the invariant culture.

If the property is a unique identifier property and is imported from the Active Directory directory service, the return object could be Byte[] instead of Sytem.GUID.

The following code example shows how to retrieve the unique identifier property:

UserProfileManager upm = new UserProfileManager();
UserProfile user = upm.GetUserProfile("domain\user");
System.Guid guidAUserProperty = GetGUIDProperty(user["AGuidProperty"]);
System.Guid GetGUIDProperty(object objPropValue) {
    if (objPropValue is System.Guid) return (Guid) objPropValue;
    else if (objPropValue is byte[]) return new Guid((byte[]) objPropValue);
    else throw new ArgumentException("...");
    return Guid.Empty;
}
Show: