The R_DhcpV4AddPolicyRange method adds an IP address range to a policy.
DWORD R_DhcpV4AddPolicyRange( [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress, [in] DHCP_IP_ADDRESS SubnetAddress, [in, unique, string] LPWSTR PolicyName, [in] LPDHCP_IP_RANGE Range );
ServerIpAddress: The IP address/host name of the DHCP server. This parameter is unused.
SubnetAddress: This is of type DHCP_IP_ADDRESS structure (section 2.2.1.2.1) that contains the IPv4 subnet ID for which the policy is being set.
PolicyName: A pointer to a null-terminated Unicode string that contains the name of the policy inside the subnet identified by the SubnetAddress parameter for which the IP address range is being set.
Range: This is a pointer to a type DHCP_IP_RANGE structure (section 2.2.1.2.31) that specifies the IP address range to be added to the policy.
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. |
|
0x00004E8F ERROR_DHCP_POLICY_NOT_FOUND |
The specified policy does not exist. |
|
0x00004E8B ERROR_DHCP_POLICY_RANGE_BAD |
The specified policy IP range is not contained within the IP address range of the scope, or the specified policy IP range is not valid. |
|
0x00004E8A ERROR_DHCP_POLICY_RANGE_EXISTS |
The specified policy IP range overlaps one of the policy IP address ranges specified. |
|
0x00004EA7 ERROR_DHCP_POLICY_FQDN_RANGE_UNSUPPORTED |
Ranges are not allowed to be added to the given policy. |
The opnum field value for this method is 113.
When processing this call, the DHCP server MUST do the following:
If the PolicyName parameter or the Range parameter is NULL, return ERROR_INVALID_PARAMETER.
If the StartAddress member of the Range parameter is greater than the EndAddress member of the Range parameter, return ERROR_DHCP_POLICY_RANGE_BAD.
Validate whether this method is authorized for write/read access as specified in section 3.5.5. If not, return ERROR_ACCESS_DENIED.
Validate that the Conditions member does not include a condition where the Type is set to the value DhcpAttrFqdn or DdnhcpAttrFqdnSingleLabel as defined in the DHCP_POL_ATTR_TYPE (section 2.2.1.1.23) enumeration. If it does, return ERROR_DHCP_POLICY_FQDN_RANGE_UNSUPPORTED<87>
Retrieve the DHCPv4Scope ADM element entry corresponding to the SubnetAddress parameter from the server ADM element DHCPv4ScopesList. If the DHCPv4Scope ADM element entry is not present, return ERROR_DHCP_SUBNET_NOT_PRESENT.
Retrieve the DHCPv4Scope.DHCPv4ScopePolicyList ADM element from the DHCPv4Scope ADM element entry. Retrieve the DHCPv4Policy ADM element entry from the DHCPv4ScopePolicyList ADM element corresponding to the specified PolicyName parameter. If there is no DHCPv4Policy ADM element that has the specified PolicyName parameter, return ERROR_DHCP_POLICY_NOT_FOUND.
Retrieve the DHCPv4Scope.DHCPv4ScopeIPRangesList ADM element. Check whether the Range parameter specified is within at least one of the DHCPv4IPRange ADM elements in the DHCPv4Scope.DHCPv4ScopeIPRangesList ADM element. Return ERROR_DHCP_POLICY_RANGE_BAD if this check fails.
Retrieve the DHCPv4Policy.Policy.Ranges ADM element. Check whether the range specified overlaps any of the DHCP_IP_RANGE ADM elements in the DHCPv4Policy.Policy.Ranges ADM element. Return ERROR_DHCP_POLICY_RANGE_EXISTS if the check succeeds.
Create a DHCP_IP_RANGE ADM element with a StartAddress member and an EndAddress member within the Range parameter. Add the DHCP_IP_RANGE ADM element created to the end of the DHCPv4Policy.Policy.Ranges ADM element, and return ERROR_SUCCESS.
Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].