The Add method adds an IWMSIPEntryIWMSIPEntry Interface to the IWMSIPList collection.

  BSTR  szAddr,
  BSTR  szMask,
  IWMSIpEntry**  pNewEntry



[in] BSTR containing an IP address in decimal notation.


[in] BSTR containing a mask used to determine whether the first parameter specifies a single IP address or a range of IP addresses. A value of indicates that the first parameter represents a single IP address.


[out] Pointer to a pointer to the newly added IWMSIPEntry object. This method calls AddRef internally. To avoid memory leaks, you must call Release when you are finished using the interface.

Return Value

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

Return code





The szAddr parameter or the szMask parameter is NULL.


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 and the mask is (that is, the bit fields are 11111111 11111111 11111111 00000000), all IP addresses from to are included in the list. For more information, see the IWMSIPEntry::put_Mask method.


#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 \

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

HRESULT         hr;
CComVariant     varIndex;
CComBSTR        bstrIP;
CComBSTR        bstrMask;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      (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;

// Add an IP to the list of banned addresses.
// Setting the mask in this case bans all IP addresses
// in the range of to
bstrIP = "";
bstrMask = "";
hr = pIPList->Add(bstrIP, bstrMask, &pIPEntry);
if (FAILED(hr)) goto EXIT;

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


Library: WMSServerTypeLib.dll.

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

See Also


IWMSIPEntry Interface

IWMSIPList Interface