Share via


IWMSAuthenticationCallback::OnAuthenticateComplete

banner art

Previous Next

IWMSAuthenticationCallback::OnAuthenticateComplete

The OnAuthenticateComplete method is implemented by the server and called by the plug-in to report the result of the authentication process.

Syntax

  HRESULT OnAuthenticateComplete(
  WMS_AUTHENTICATION_RESULT  AuthResult,
  VARIANT  ChallengeBlob
  VARIANT  Context
);

Parameters

AuthResult

[in] Member of the WMS_AUTHENTICATION_RESULT enumeration type that contains the result of the authentication process. This must be one of the following values.

Value Description
WMS_AUTHENTICATION_SUCCESS Notifies the server that authentication has succeeded.
WMS_AUTHENTICATION_DENIED Notifies the server that authentication has been denied.
WMS_AUTHENTICATION_CONTINUE Notifies the server that the authentication process is not complete, and that the server must request more data from the user.
WMS_AUTHENTICATION_ERROR Notifies the server that an error occurred during the authentication process.

ChallengeBlob

[in] VARIANT containing a binary large object (BLOB). This value is only relevant when the AuthResult parameter contains WMS_AUTHENTICATION_CONTINUE. The server passes the BLOB, unaltered, to the client. If you are creating a custom authentication plug-in, the value you supply is specific to the type of authentication process that the plug-in implements. For example, a Digest Authentication plug-in passes the realm to the client, but an anonymous authentication plug-in does not pass a value.

Context

[in] VARIANT containing a value defined by the server to identify which call to IWMSAuthenticationContext::Authenticate the plug-in is responding to when it calls OnAuthenticateComplete. You must pass this value back unaltered.

Return Values

If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.

Remarks

The server calls the IWMSAuthenticationContext::Authenticate method to authenticate a client. The plug-in calls the OnAuthenticateComplete method to send the results of the authentication process to the server.

Example Code

HRESULT CAuthentContext::Authenticate(
                VARIANT ResponseBlob,
                IWMSContext *pUserCtx,
                IWMSContext *pPresentationCtx,
                IWMSCommandContext *pCommandContext,
                IWMSAuthenticationCallback *pCallback,
                VARIANT Context )
{
    // Declare variables.
    
    DWORD decodeLen;
    DWORD dwState;
    BOOL  fRetVal = TRUE;
    DWORD dwUserNameLen = 0;
    CComVARIANT ChallengeBlob;
    char* pszUserName;
    char* pszDomain;
    char* pszPassword;

    dwState = WMS_AUTHENTICATION_ERROR;

    // TODO: Decode the user token to find the number of characters
    // in the response BLOB. This is represented in the following
    // example code by decodeLen.
    // Create a buffer to store the client response.
    
    char* pszCredBuf = (char*) _alloca( decodeLen );

    // Retrieve the domain, user name, and password from the 
    // decoded credential. The CrackUserCredential() function 
    // is user-defined.

    CrackUserCredential( pszCredBuf, 
                         &pszUserName, 
                         &pszDomain, 
                         &pszPassword ) )

    // Try to log the user on to the server.

    fRetVal = LogonUserA(pszUserName,
                         pszDomain,
                         pszPassword,
                         LOGON32_LOGON_NETWORK,
                         LOGON32_PROVIDER_DEFAULT,
                         &m_hToken );
    if (!fRetVal)
    {
        dwState = WMS_AUTHENTICATION_DENIED;
    }
    else
    {
        dwState = WMS_AUTHENTICATION_SUCCESS;
    }

    pCallback->OnAuthenticateComplete( dwState, 
                                       ChallengeBlob, 
                                       Context );

    return( S_OK );
}

Requirements

Header: authen.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Previous Next