Share via


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)

Syntax

'Declaration
Public ReadOnly Default Property Item ( _
    strPropName As String _
) As UserProfileValueCollection
    Get
'Usage
Dim instance As UserProfile
Dim strPropName As String
Dim value As UserProfileValueCollection

value = instance(strPropName)
public UserProfileValueCollection this[
    string strPropName
] { get; }

Parameters

Property value

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

Remarks

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.

Examples

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;
}

See also

Reference

UserProfile class

UserProfile members

Microsoft.Office.Server.UserProfiles namespace