The R_DhcpRemoveSubnetElementV5 method removes an IPv4 subnet element from the specified IPv4 subnet defined on the DHCPv4 server. The subnet elements can be IPv4 reservation for DHCPv4 or BOOTP clients, IPv4 range, or IPv4 exclusion range for DHCPv4 or BOOTP clients.

 DWORD R_DhcpRemoveSubnetElementV5(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [in, ref] LPDHCP_SUBNET_ELEMENT_DATA_V5 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 the IPv4 subnet element is removed.

RemoveElementInfo: This is a pointer of type DHCP_SUBNET_ELEMENT_DATA_V5 (section 2.2.1.2.38) that contains 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) that defines 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 the DHCPv4 client lease record on the DHCPv4 server.

Return Values: A 32-bit unsigned integer value that indicates return status. A return value of 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

This error can occur for any of the following reasons:

  • The specified IPv4 subnet element cannot be removed because at least one IPv4 address has been leased out to a client in 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 on the scope IP address range cannot be performed until the policy IP address range is suitably modified.

The opnum field value for this method is 39.

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

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