Share via


IMSCSAuthManager2::GenerateEncryptionKey Method

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

Use this method to generate an encryption key for encrypting/decrypting cookie and query string data used for tickets.

HRESULT IMSCSAuthManager::GenerateEncryptionKey(
    BSTR* pbstrRet
);
Function GenerateEncryptionKey() As String

Parameters

  • pbstrRet
    [C++]

    [out, retval] A pointer to a BSTR used to return a copy of the encryption key. [Visual Basic]

    Not applicable.

Return Value

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] If this method completes successfully, it returns a String that contains the encryption key.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM error that this method can return.

Constant

Value

Description

E_UPM_AUTHMANAGER_GENERATE_ENCRYPTIONKEY_FAILED

[C++] 0xC1004C26

[Visual Basic] &HC1004C26

An error occurred while generating the encryption key using CryptoAPI, the Windows API that supports encryption features.

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

[C++] The pbstrRet parameter contains valid data only if the method completes successfully.

This method is one of the few AuthManager methods used in C++ applications.

This method is used by Commerce Server setup and Commerce Server Site Packager components during installation, and can be used to change the encryption key at a later time.

The encryption key is stored as part of the site configuration resource properties in the Administrative database.

Example

' oAuthManager is a AuthManager object.

sEncryptionKey = oAuthManager.GenerateEncryptionKey()

See Also

Other Resources

AuthManager Object