3.2.4.112 R_DhcpV4DeletePolicy (Opnum 111)

The R_DhcpV4DeletePolicy method deletes the specified policy.

 DWORD R_DhcpV4DeletePolicy(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] BOOL ServerPolicy,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [in, unique, string] LPWSTR PolicyName
 );

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

ServerPolicy: This is of type BOOL and indicates whether the server level policy or scope level policy is being deleted.

SubnetAddress: This is of type DHCP_IP_ADDRESS data type (section 2.2.1.2.1) that identifies the IPv4 subnet from which the policy is being deleted.

PolicyName: A pointer to a null-terminated Unicode string that contains the name of the policy deleted.

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. Otherwise, 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 to 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.

The opnum field value for this method is 111.

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

  • If the ServerPolicy parameter is TRUE and the SubnetAddress parameter is not NULL, return ERROR_INVALID_PARAMETER.

  • If the ServerPolicy parameter is FALSE and the SubnetAddress parameter is NULL, return ERROR_INVALID_PARAMETER.

  • If the PolicyName parameter is NULL or if the Policy parameter is NULL, return ERROR_INVALID_PARAMETER.

  • Validate whether this method is authorized for write/read access as specified in section 3.5.5. If not, return ERROR_ACCESS_DENIED.

  • If the ServerPolicy parameter is TRUE:

    • Retrieve the DHCPv4ServerPolicyList ADM element and get the DHCPv4Policy ADM element from the DHCPv4ServerPolicyList ADM element for the specified PolicyName parameter. If there is no DHCPv4Policy ADM element with the specified PolicyName parameter, return ERROR_DHCP_POLICY_NOT_FOUND.

    • Iterate through the server ADM element DHCPv4ServerPolicyOptionValuesList and retrieve the DHCPv4PolicyOptionValue entries corresponding to the policy specified by the retrieved DHCPv4Policy.Policy.PolicyName. Remove these entries from DHCPv4ServerPolicyOptionValuesList.

    • Delete the specific DHCPv4Policy ADM element and return ERROR_SUCCESS.

  • If the ServerPolicy parameter is FALSE:

    • Retrieve the DHCPv4ScopesList ADM element and get the DHCPv4Scope ADM element from the DHCPv4ScopesList ADM element where the SubnetAddress ADM element in the DHCPv4Scope ADM element matches the specified SubnetAddress parameter.

    • If there is no DHCPv4Scope ADM element matching the specified SubnetAddress parameter, return ERROR_DHCP_SUBNET_NOT_PRESENT.

    • Retrieve the DHCPv4Scope.DHCPv4ScopePolicyList ADM element and get the DHCPv4Policy ADM element from the DHCPv4Scope.DHCPv4ScopePolicyList ADM element that has the same name as the specified PolicyName parameter.

    • If there is no DHCPv4Policy ADM element with the specified PolicyName parameter, return ERROR_DHCP_POLICY_NOT_FOUND.

    • Iterate through the scope ADM element DHCPv4Scope.DHCPv4ScopePolicyOptionValuesList and retrieve the DHCPv4PolicyOptionValue entries corresponding to the policy specified by the retrieved DHCPv4Policy.Policy.PolicyName ADM element. Remove these entries from DHCPv4Scope.DHCPv4ServerPolicyOptionValuesList.

    • Delete the specific DHCPv4Policy ADM element and return ERROR_SUCCESS.

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