Share via


IWMSAuthenticationContext::Authenticate

banner art

Previous Next

IWMSAuthenticationContext::Authenticate

The server calls the Authenticate method to verify client credentials.

Syntax

  HRESULT Authenticate(
  VARIANT  ResponseBlob,
  IWMSContext*  pUserCtx,
  IWMSContext*  pPresentationCtx,
  IWMSCommandContext*  pCommandContext,
  IWMSAuthenticationCallback*  pCallback,
  VARIANT  varContext
);

Parameters

ResponseBlob

[in] VARIANT containing client authentication data passed from the server. The exact nature of the data is specific to the authentication protocol being used.

pUserCtx

[in] Pointer to the IWMSContext interface containing the user context. The plug-in fills the context.

pPresentationCtx

[in] Pointer to the IWMSContext interface containing the presentation context. The plug-in fills the context.

pCommandContext

[in] Pointer to the IWMSCommandContext interface containing the request context. The plug-in fills the context.

pCallback

[in] Pointer to an IWMSAuthenticationCallback interface. The plug-in calls the IWMSAuthenticationCallback::OnAuthenticateComplete method to send the results of the authentication process to the server.

varContext

[in] VARIANT containing a value defined by the server to identify which call to Authenticate the plug-in is responding to when it calls IWMSAuthenticationCallback::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 Authenticate method. The plug-in must call the IWMSAuthenticationCallback::OnAuthenticateComplete method.

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