Поделиться через


UserID Property

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

Gets or sets the user identification for the current user.

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

Syntax

'Declaration
Public Property UserID As String
'Usage
Dim instance As CommerceContext
Dim value As String

value = instance.UserID

instance.UserID = value
public string UserID { get; set; }
public:
property String^ UserID {
    String^ get ();
    void set (String^ value);
}
public function get UserID () : String
public function set UserID (value : String)

Property Value

Type: System..::.String
The user identification for the current user.

Exceptions

Exception Condition
CommerceException

Thrown when 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 UserID 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 it from one of the following sources:

  1. If Commerce Server Authentication is being used, user ID is obtained from the AuthTicket object, if it exists.

  2. If ASP.Net Authentication is being used, user ID is obtained by using the HttpContext.Current.User.Identity.Name value and looking it up in the Profiles Store.

The way in which this lookup is done can be configured in the CommerceServer/profiles section of the web.config file.

If the UserID property has not been previously set, the get method tries (if the Authentication module is configured) to retrieve the UserID property from the current AuthenticationInfo instance.

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