שתף באמצעות


UserProfile Property

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Gets or sets the profile for the current user.

Namespace:  Microsoft.CommerceServer.Runtime
Assembly:  Microsoft.CommerceServer.Runtime (in Microsoft.CommerceServer.Runtime.dll)

Syntax

'Declaration
Public Property UserProfile As Profile
'Usage
Dim instance As CommerceContext
Dim value As Profile

value = instance.UserProfile

instance.UserProfile = value
public Profile UserProfile { get; set; }
public:
property Profile^ UserProfile {
    Profile^ get ();
    void set (Profile^ value);
}
public function get UserProfile () : Profile
public function set UserProfile (value : Profile)

Property Value

Type: Microsoft.CommerceServer.Runtime.Profiles..::.Profile
The profile for the current user.

Exceptions

Exception Condition
CommerceException

Thrown if the UserProfile property has not been previously set and either the UserID or ProfileSystem property is nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

For more information about how the CommerceServer membership provider uses the UserProfile property, see How to Enable Logons by Using the Commerce Server Membership Provider.

The.OrganizationProfile property is dependent on being set by the UserProfile property or set explicitly. The UserProfile property is dependent on being set by the UserID property or set explicitly, and the UserID property is dependent upon being set explicitly or obtaining the ID from the AuthTicket object, if it exists.

If this property is accessed before it has been explicitly set, the profile will be automatically read from the profiling system using the UserID property and the settings in the profiles section in the Web.config file. The property returns nullNothingnullptra null reference (Nothing in Visual Basic) if the user profile does not exist.

The section in Web.config that specifies the user ID is as follows:

The last 3 keys are all optional; if no value is specified, the values shown above are used as defaults. userIdSource can have two values: ASP.NET or UPM (case insensitive). Any other value will cause a CommerceException to be thrown. These new keys come into play when the CommerceContext.Current.UserID property is queried for the first time. If ASP.NET is specified, the CommerceContext.Current.UserID key will be populated by looking up the profile specified in the profileDefinition attribute (UserObject by default). The lookup is done by searching for a profile object whose userIdKey property is equal to HttpContext.Current.User.Identity.Name. The result of the search is stored in CommerceContext.Current.UserProfile. The profile search is done only if the CommerceContext.Current.UserProfile object is nullNothingnullptra null reference (Nothing in Visual Basic). If this property is not nullNothingnullptra null reference (Nothing in Visual Basic), it's contents are used to get the user ID. After getting the user profile, the userIdTarget key of the profile is looked up to determine the value of UserID. The CommerceContext.Current.UserID property can return nullNothingnullptra null reference (Nothing in Visual Basic) if the profile search returns nullNothingnullptra null reference (Nothing in Visual Basic) or if the userIdTarget key does not exist.

Permissions

See Also

Reference

CommerceContext Class

CommerceContext Members

Microsoft.CommerceServer.Runtime Namespace