Required for setting the security token that will be used for all connections in the current thread or process.

A call to either SetThreadSecurityToken or SetProcessSecurityToken is required to communicate with the Content Engine server. When a SecurityToken is specified, a request to the server is limited, through authorization access control, to the operations that have been granted to the specified principal. Correspondingly, if a locale is specified, the server attempts to return localizable messages, such as exception text, according to the language code specified by the locale.

As noted above, UserContext operations are performed on a per-thread or per-process basis. When working with multiple locales, for example when servicing requests via a thread pool, you must explicitly call SetLocale at the beginning of each new thread (request). The following code snippet illustrates the call to make at the startup phase of every request, where reqLocale is the locale (System.Globalization.CultureInfo) to be used for this request:

 Copy Code
            UserContext uc = UserContext.Get();
            uc.SetLocale(reqLocale);
            

The following tables list the members exposed by UserContext.

Public Methods

 NameDescription
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (inherited from Object)
Public methodStaticGetThis method returns the UserContext object associated with the current thread. When no user context has been set, a default one exists containing the current locale for the current thread.
Public methodGetHashCodeServes as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (inherited from Object)
Public methodGetLocaleReturns the locale identifier for this user context. If no locale has been set, this method returns the locale defined for the current thread. For more information, see the LocaleName property.
Public methodStaticGetTokenReturns the SecurityToken object that is currently in effect.

If there is a Token associated with the current thread then this method will return it. If not, then it will return the Token associated with the current process. If there are no associated Tokens, then this method returns Null.

Public methodGetTypeGets the Type of the current instance. (inherited from Object)
Public methodSetLocaleSets the locale identifier for this user context. For more information, see the LocaleName property.
Public methodStaticSetProcessSecurityTokenAssociates the SecurityToken with all threads in this process (global). This method is required for setting the security token that will be used for all connections in the current process.
Public methodStaticSetThreadSecurityTokenAssociates the SecurityToken with the current thread. This method is required for setting the security token that will be used for all connections in the current thread.
Public methodToStringReturns a String that represents the current Object. (inherited from Object)
Top

Protected Methods

 NameDescription
Family methodFinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
Family methodMemberwiseCloneCreates a shallow copy of the current Object. (inherited from Object)
Top

See Also