Partager via


IMSCSAuthManager2::IsAuthenticated Method

Use this method to determine whether the current user has a valid MSCSAuth ticket. This method also allows the determination of whether the user has been authenticated within a specified period of time.

HRESULT IMSCSAuthManager::IsAuthenticated(
    long TimeWindow,
    VARIANT_BOOL* pboolAuth
);
Function IsAuthenticated(
    Optional TimeWindow As Long
) As Boolean

Parameters

  • TimeWindow
    [C++]

    [in, optional, defaultvalue (0)] A long that contains a time period in minutes.

    [Visual Basic]

    [in, optional, defaultvalue (0)] A Long that contains a time period in minutes.

  • pboolAuth
    [C++]

    [out, retval] A pointer to a VARIANT_BOOL containing the authentication status of the current user.

    [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 Boolean that indicates the authentication status of the current user.

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.

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

[C++] 0xC1004C24

[Visual Basic] &HC1004C24

This method should only be called within an ASP page.

MSG_UPM_AUTH_SITE_NEEDED_ERROR

[C++] 0xC1004C10

[Visual Basic] &HC1004C10

The Initialize method must be called with the installed site name before calling this method.

[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 pboolAuth parameter contains valid data only if the method completes successfully.

A MSCSAuth ticket contains the time the user last logged in and a time window of validity. The ticket is no longer valid if the time since the last login has exceeded the time window specified in the SetAuthTicket method when the ticket was generated.

The optional time window parameter, TimeWindow, of this method allows checking whether the time since the user last logged in has exceeded a shorter time interval than the time window specified by the SetAuthTicket method. The default value of zero (0) is equivalent to setting the time window to the same value as specified in the SetAuthTicket method.

This method returns False if the user does not have an MSCSAuth ticket, the ticket is invalid, or the time since the user last logged in has exceeded the specified time window.

If the ticket is within five minutes of expiring, the last login time is refreshed to the current time, allowing an additional period for the ticket to be valid.

Ensure a log-off page is created and called for any logged-in user. The log-off page should either expire the MSCSAuth cookie or clear its contents.

Example

' oAuthManager is a AuthManager object.

bAuth = oAuthManager.IsAuthenticated(lWindow)

See Also

Other Resources

AuthManager Object