3.1.4.8 R_DhcpDeleteSubnet (Opnum 7)

The R_DhcpDeleteSubnet method deletes an IPv4 subnet from the DHCPv4 server. The ForceFlag defines the behavior of the operation when an IP address from the subnet has been allocated to some DHCPv4 client.

 DWORD R_DhcpDeleteSubnet(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [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), uniquely identifying the IPv4 subnet that needs to be removed from the DHCPv4 server.

ForceFlag: This is of type DHCP_FORCE_FLAG (section 2.2.1.1.9) enumeration. If the flag is set to DhcpNoForce and an IPv4 address from this subnet has been served to some DHCPv4/BOOTP client, the IPv4 subnet is not deleted; if the flag is set to DhcpFullForce, the IPv4 subnet is deleted along with the DHCPv4 client lease record on the DHCPv4 server; if the flag is set to DhcpFailoverForce, the IPv4 subnet is deleted along with the DHCPv4 client lease record on the DHCPv4 server but the DNS resource records corresponding to the DHCPv4 client lease records are not deleted from the DNS 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 cannot be removed because at least one IPv4 address has been leased out to some client from the subnet.

0x00004E2D

ERROR_DHCP_JET_ERROR

An error occurred while accessing the DHCP server database.

0x00004E90

ERROR_DHCP_FO_SCOPE_ALREADY_IN_RELATIONSHIP

The specified IPv4 subnet is part of a failover relationship and cannot be deleted without first removing the failover relationship.

The opnum field value for this method is 7.

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

  • Validate if this method is authorized for read/write access per section 3.5.5. If not, return the error ERROR_ACCESS_DENIED.

  • Retrieve the Abstract Data Model (ADM) element DHCPv4Scope entry corresponding to the SubnetAddress parameter from the server ADM element DHCPv4ScopesList. If the DHCPv4Scope ADM element entry is not found, return ERROR_DHCP_SUBNET_NOT_PRESENT.

  • If the DHCPv4Scope.IsFailover ADM element is set to TRUE, return ERROR_DHCP_FO_ALREADY_IN_RELATIONSHIP.<29>

  • If this subnet has served the IPv4 address to some DHCPv4/BOOTP clients, and ForceFlag is set to DhcpNoForce, return error ERROR_DHCP_ELEMENT_CANT_REMOVE; else, delete the DHCPv4Scope ADM element entry corresponding to the SubnetAddress from the DHCPv4ScopesList ADM element.

  • If the ForceFlag is set to DhcpFullForce, delete all DNS PTR resource records corresponding to the DHCPv4 client lease records from the DNS server, using the message for DNS PTR resource record deletion ([RFC1035] sections 3.3 and 4.1, [RFC2136] sections 2.5 and 3.4) and the data shown in the following table.

    DNS Fields

    Values

    NAME ([RFC1035] sections 3.5 and 4.1)

    The IP address stored as the client IP address in the DHCPv4 client lease record in the DHCP server database.

  • Return ERROR_SUCCESS.

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