Share via


WMS IP Address Authorization Plug-in Properties

You can use the WMS IP Address Authorization plug-in to allow or deny access to specific IP addresses or to a group of IP addresses by specifying a subnet address and mask. This plug-in is useful, for example, if you want to allow access only to users on a specific intranet. Or, if you believe there is a security violation on a server, you could quickly enable this plug-in to deny access to the IP address that is violating security. For administration information about this plug-in, see Windows Media Services Help.

There are three interfaces that can be used to configure the WMS IP Address Authorization plug-in programmatically. The IWMSIPEntry interface exposes the following properties.

Property

Description

Address

Specifies and retrieves an IP address or range of IP addresses that can be used to allow or disallow client connections.

Mask

Specifies and retrieves an IP address mask.

The IWMSIPList interface contains a collection of IWMSIPEntry objects and exposes the following methods.

Method

Description

Add

Adds an IWMSIPEntry object to the IWMSIPList collection.

Remove

Removes a specific IWMSIPEntry object from the IWMSIPList collection.

The IWMSIPAdmin interface exposes the following properties.

Property

Description

AccessListOptions

Retrieves an enumeration value indicating default access permissions for unspecified IP addresses.

AllowIP

Retrieves an IWMSIPList object containing a collection of IP addresses a client can use to connect to the server.

DisallowIP

Retrieves an IWMSIPList object containing a collection of IP addresses a client cannot use to connect to the server.

The following examples illustrate how to use the IWMSIPAdmin interface to retrieve a list of restricted IP addresses.

Note

The administrative user interface included with the plug-in allows restrictions based only on IPv4 addresses. You can use the custom interface exposed by the plug-in to impose restrictions based on IPv6 addresses. For more information see IWMSIPList.AddIWMSIPList.Add (Visual Basic .NET).

Visual Basic .NET Example

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

Private Sub SetIPAddrPluginProps() 

' Declare variables.
Dim Server As WMSServer
Dim Plugin As IWMSPlugin
Dim IPAdmin As IWMSIPAdmin
Dim IPList As IWMSIPList

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

    ' Retrieve the IWMSPlugin object for the
    ' WMS IP Address Authorization plug-in.
    Plugin = Server.EventHandlers("WMS IP Address Authorization")

    ' Retrieve the administrative interface for the
    ' WMS IP Address Authorization plug-in.
    IPAdmin = Plugin.CustomInterface()

    ' Configure the plug-in to allow all IP addresses
    ' except those specifically set to be denied.
    IPAdmin.AccessListOptions = WMS_IP_ACCESS_OPTIONS.WMS_IP_ACCESS_ALLOW_BY_DEFAULT

    ' Retrieve the list of banned IP addresses.
    IPList = IPAdmin.DisallowIP
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;
IWMSIPAdmin IPAdmin;
IWMSIPList IPList;

try
{
    // Create a new WMSServer object.
    Server = new WMSServerClass();
    
    // Retrieve the IWMSPlugin object for the
    // IP address authorization plug-in.
    Plugin = Server.EventHandlers["WMS IP Address Authorization"];
    
    // Retrieve the administrative interface for the
    // IP address authorization plug-in.
    IPAdmin = (IWMSIPAdmin)Plugin.CustomInterface;
    
    // Configure the plug-in to allow all IP addresses
    // except those specifically set to be denied.
    IPAdmin.AccessListOptions = WMS_IP_ACCESS_OPTIONS.WMS_IP_ACCESS_ALLOW_BY_DEFAULT;
    
    // Retrieve the list of banned IP addresses.
    IPList = IPAdmin.DisallowIP;
}
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;
IWMSIPAdmin*        pIPAdmin = NULL;
IWMSIPList*         pIPList = NULL;
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 authorization plug-ins.
hr = pServer->get_EventHandlers(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPlugin interface for the
// WMS IP Address Authorization plug-in.
varIndex = "WMS IP Address Authorization";
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
// IWMSIPAdmin interface.
hr = pDispatch->QueryInterface(IID_IWMSIPAdmin, (void**)&pIPAdmin);
if (FAILED(hr)) goto EXIT;

// Configure the plug-in to allow all IP addresses
// except those specifically set to be denied.
hr = pIPAdmin->put_AccessListOptions(WMS_IP_ACCESS_ALLOW_BY_DEFAULT);
if (FAILED(hr)) goto EXIT;

// Retrieve the list of banned IP addresses.
hr = pIPAdmin->get_DisallowIP(&pIPList);
if (FAILED(hr)) goto EXIT;

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

See Also

Reference

IWMSIPAdmin Interface

IWMSIPAdmin Object (C#)

IWMSIPAdmin Object (Visual Basic .NET)

IWMSIPEntry Interface

IWMSIPEntry Object (C#)

IWMSIPEntry Object (Visual Basic .NET)

IWMSIPList Interface

IWMSIPList Object (C#)

IWMSIPList Object (Visual Basic .NET)

Concepts

Programming System Plug-in Properties