The R_DhcpRemoveSubnetElement method removes an IPv4 subnet element from an IPv4 subnet defined on the DHCPv4 server.

 DWORD R_DhcpRemoveSubnetElement(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [in, ref] LPDHCP_SUBNET_ELEMENT_DATA RemoveElementInfo,
   [in] DHCP_FORCE_FLAG ForceFlag
 );

ServerIpAddress: The IP address/host name of the DHCP server. This parameter is unused.

SubnetAddress: This is of type DHCP_IP_ADDRESS (section 2.2.1.2.1) that contains the IPv4 subnet ID from which subnet elements are enumerated.

RemoveElementInfo: This is a pointer of type DHCP_SUBNET_ELEMENT_DATA (section 2.2.1.2.33), containing the IPv4 subnet element that needs to be removed from the IPv4 subnet.

ForceFlag: This is of type DHCP_FORCE_FLAG (section 2.2.1.1.9), defining the behavior of this method. If the flag is set to DhcpNoForce and this subnet has served the IPv4 address to some DHCPv4\BOOTP clients, the IPv4 range is not deleted; if the flag is set to DhcpFullForce, the IPv4 range is deleted along with DHCPv4 client lease record on the DHCPv4 server.

Return Values: A 32-bit unsigned integer value that indicates return status. A return value ERROR_SUCCESS (0x00000000) indicates that the operation was completed successfully, else it contains a Win32 error code, as specified in [MS-ERREF]. This error code value can correspond to a DHCP-specific failure, which takes a value between 20000 and 20099, or any generic failure.

Return value/code

Description

0x00000000

ERROR_SUCCESS

The call was successful.

0x00004E25

ERROR_DHCP_SUBNET_NOT_PRESENT

The specified IPv4 subnet does not exist.

0x00004E27

ERROR_DHCP_ELEMENT_CANT_REMOVE

  • The specified IPv4 subnet element cannot be removed because at least one IPv4 address has been leased out to a client from the subnet.

  • The starting address of the specified IPv4 exclusion range is not part of any exclusion range configured on the server.

  • There is an error in deleting the exclusion range from the database.

0x00004E2D

ERROR_DHCP_JET_ERROR

An error occurred while accessing the DHCP server database.

0x00004E37

ERROR_DHCP_INVALID_RANGE

The specified IPv4 range does not match an existing IPv4 range.

0x00004E90

ERROR_SCOPE_RANGE_POLICY_RANGE_CONFLICT

There is an IP address range configured for a policy in this scope. This operation cannot be performed until the policy IP range is suitably modified.

The opnum field value for this method is 6.

When processing this call, the DHCP server MUST do the following:

Exceptions Thrown: No exceptions SHOULD be thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].