WMS Digest Authentication Plug-in Properties

Note

   This plug-in is available only on Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; and Windows Server 2008. For administration information about this plug-in, see Windows Media Services Help.

The WMS Digest Authentication plug-in uses a challenge/response HTTP authentication protocol that does not require sending a password over the network as clear text. Instead, the plug-in uses a hashed (digested) version of the password to authenticate the user. Username/password pairs are associated with realms to allow the same authorization information to be used for multiple resources. The server uses the realm instead of a user name or password to obtain the correct decryption key for the digest password. You can use the IWMSAdminRealm interface to specify the realm that the Windows Media server must use to authenticate a client. This is illustrated by the following examples.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop 
Imports System.Runtime.InteropServices

Private Sub SetDigestPluginProps() 

' Declare variables.
Dim Server As WMSServer
Dim Plugin As IWMSPlugin
Dim AdminRealm As IWMSAdminRealm

Try
    ' Create a new WMSServer object.
    Server = New WMSServer()

    ' Retrieve the IWMSPlugin object for the 
    ' WMS Digest Authentication plug-in.
    Plugin = Server.Authenticators.Item("WMS Digest Authentication")

    ' Retrieve the administrative interface for the
    ' WMS Digest Authentication plug-in.
    AdminRealm = Plugin.CustomInterface()

    ' Specify the realm.
    AdminRealm.Realm = "MyRealm"
Catch excCom As COMException
    ' TODO: Handle COM exceptions.
Catch exc As Exception
    ' Todo: Handle exceptions here.
Finally
    ' TODO: Perform clean-up here.
End Try

End Sub 

C# Example

using Microsoft.WindowsMediaServices.Interop; 
using System.Runtime.InteropServices;

// Declare variables.
WMSServer Server;
IWMSPlugin Plugin;
IWMSAdminRealm AdminRealm;

try
{
    // Create a new WMSServer object.
    Server = new WMSServerClass();
    
    // Retrieve the IWMSPlugin object for the 
    // digest authentication plug-in.
    Plugin = Server.Authenticators["WMS Digest Authentication"];
    
    // Retrieve the administrative interface for the
    // digest authentication plug-in.
    AdminRealm = (IWMSAdminRealm)Plugin.CustomInterface;
    
    // Specify the realm.
    AdminRealm.Realm = "MyRealm";
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception exc)
{
    // TODO: Handle exceptions here.
}
finally
{
    // TODO: Perform clean-up here.
}

C++

#include <windows.h>
#include <atlbase.h>

// To access system plug-in interfaces, the
// type library must be imported as shown.
#import "WMSServerTypeLib.dll" no_namespace named_guids \
                               raw_interfaces_only

// Declare variables and interface pointers.
IWMSServer*         pServer = NULL;
IWMSPlugins*        pPlugins = NULL;
IWMSPlugin*         pPlugin = NULL;
IDispatch*          pDispatch = NULL;
IWMSAdminRealm*     pAdminRealm = NULL;
CComBSTR            bstrRealm;
CComVariant         varIndex;
HRESULT             hr = S_OK;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to an IWMSPlugins interface
// containing the collection of authentication plug-ins.
hr = pServer->get_Authenticators(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPlugin interface for the
// WMS Digest Authentication plug-in.
varIndex = "WMS Digest Authentication";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;

// Retrieve an IDispatch pointer to the
// administration interface for the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Call QueryInterface() to retrieve a pointer to the
// IWMSAdminRealm interface.
hr = pDispatch->QueryInterface(IID_IWMSAdminRealm, (void**)&pAdminRealm);
if (FAILED(hr)) goto EXIT;

// Retrieve the realm.
hr = pAdminRealm->get_Realm(&bstrRealm);
if (FAILED(hr)) goto EXIT;

// Specify a new realm.
bstrRealm = "MyRealm";
hr = pAdminRealm->put_Realm(bstrRealm);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Reference

IWMSAdminRealm Interface

IWMSAdminRealm Object (C#)

IWMSAdminRealm Object (Visual Basic .NET)

Concepts

Programming System Plug-in Properties