IWMSIPEntry::put_Mask

banner art

Previous Next

IWMSIPEntry::put_Mask

The put_Mask method specifies an IP address mask.

Syntax

  HRESULT put_Mask(
  BSTR  value
);

Parameters

value

[in] BSTR containing the IP mask.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_FAIL 0x80004005 The server cannot find an IP address entry list.
E_INVALIDARG 0x80070057 The value parameter is NULL.

Remarks

When the address, which is specified by the IWMSIPEntry::put_Address method, refers to a valid IPv6 address the mask must be set to a single numeric value representing the IPv6 prefix length. For example, if the IP address is 3FFE:5000::1, the mask might be set to 127. When the address refers to a valid IPv4 address, the mask must be set using decimal notation. The server treats the mask as a 32-bit value. Each bit in the mask is compared to the corresponding bit in the IP address. When the bit value in the mask is 1, the corresponding bit in the IP address is included in the list. When the bit value in the mask is 0, all values are included. For example, if the IP address in the list is 134.123.123.20 and the mask is 255.255.255.0 (that is, the bit fields are 11111111 11111111 11111111 00000000), all IP addresses from 134.123.123.0 to 134.123.123.255 are included in the list.

Example Code

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.

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

// Declare variables and interfaces.
IWMSServer      *pServer;
IWMSPlugins     *pPlugins;
IWMSPlugin      *pPlugin;
IDispatch       *pDispatch;
IWMSIPAdmin     *pIPAdmin;
IWMSIPList      *pIPList;
IWMSIPEntry     *pIPEntry;

HRESULT         hr;
CComVariant     varIndex;
CComBSTR        bstrMask;

// 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 event handler plug-ins.
hr = pServer->get_EventHandlers(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPlugin interface
// of the plug-in to be configured.
varIndex = "WMS IP Address Authorization";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the custom interface
// of the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Query the specific administration interface
// for the plug-in.
hr = pDispatch->QueryInterface(IID_IWMSIPAdmin,
                              (void **)&pIPAdmin);
if (FAILED(hr)) goto EXIT;

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

// Retrieve a pointer to the first banned address.
varIndex = 0;
hr = pIPList->get_Item(varIndex, &pIPEntry);
if (FAILED(hr)) goto EXIT;

// Set the mask for the banned address.
bstrMask = "255.255.255.0";
pIPEntry->put_Mask(bstrMask);

EXIT:

Requirements

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next