<div class="content"><p> </p><p>The <b>R_DhcpV4AddPolicyRange</b> method adds an IP address
range to a policy.</p><dl>
<dd>
<div><pre> 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
 );
</pre></div>
</dd></dl><p><b>ServerIpAddress: </b>The IP address/host name of
the DHCP server. This parameter is unused.</p><p><b>SubnetAddress: </b>This is of type <b>DHCP_IP_ADDRESS</b>
structure (section <span><a href="5122557b-b85d-4982-8ffb-98d8d934e353" data-linktype="relative-path">2.2.1.2.1</a></span>) that
contains the IPv4 subnet ID for which the <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_52323544-69e0-4172-8921-2711cbda988e" data-linktype="relative-path">policy</a></span> is being set.</p><p><b>PolicyName: </b>A pointer to a null-terminated
Unicode string that contains the name of the policy inside the subnet
identified by the <i>SubnetAddress</i> parameter for which the IP address range
is being set.</p><p><b>Range: </b>This is a pointer to a type <b>DHCP_IP_RANGE</b>
structure (section <span><a href="29a03b34-249e-4bd8-a118-e708dadbf22b" data-linktype="relative-path">2.2.1.2.31</a></span>) that
specifies the IP address range to be added to the policy.</p><p><b>Return Values: </b>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 <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>.
This error code value can correspond to a DHCP-specific failure, which takes a
value between 20000 and 20099, or to any generic failure.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>ERROR_SUCCESS</p>
  </td>
  <td>
  <p>The call was successful.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E25</p>
  <p>ERROR_DHCP_SUBNET_NOT_PRESENT</p>
  </td>
  <td>
  <p>The specified IPv4 subnet does not exist.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E8F</p>
  <p>ERROR_DHCP_POLICY_NOT_FOUND</p>
  </td>
  <td>
  <p>The specified policy does not exist.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E8B</p>
  <p>ERROR_DHCP_POLICY_RANGE_BAD</p>
  </td>
  <td>
  <p>The specified <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_eb84404c-885e-48de-9f2a-ae76b8b3c5be" data-linktype="relative-path">policy IP range</a></span> is
  not contained within the IP address range of the scope, or the specified
  policy IP range is not valid.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E8A</p>
  <p>ERROR_DHCP_POLICY_RANGE_EXISTS</p>
  </td>
  <td>
  <p>The specified policy IP range overlaps one of the
  policy IP address ranges specified.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004EA7</p>
  <p>ERROR_DHCP_POLICY_FQDN_RANGE_UNSUPPORTED</p>
  </td>
  <td>
  <p>Ranges are not allowed to be added to the given
  policy.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The opnum field value for this method is 113.</p><p>When processing this call, the DHCP server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>If the <i>PolicyName</i> parameter or the <i>Range</i> parameter
is NULL, return ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the <b>StartAddress</b> member of the <i>Range</i> parameter
is greater than the <b>EndAddress</b> member of the <i>Range</i> parameter,
return ERROR_DHCP_POLICY_RANGE_BAD.</p>
</li><li><p><span><span> 
</span></span>Validate whether this method is authorized for write/read access
as specified in section <span><a href="38840bd0-0a5a-47ed-bc69-0dd870d33aec" data-linktype="relative-path">3.5.5</a></span>. If not,
return ERROR_ACCESS_DENIED.</p>
</li><li><p><span><span> 
</span></span>Validate that the <b>Conditions</b> member does not include a
condition where the Type is set to the value DhcpAttrFqdn or DdnhcpAttrFqdnSingleLabel
as defined in the <span><a href="f05fc88f-3ac7-4c44-9998-40e4acaeb776" data-linktype="relative-path">DHCP_POL_ATTR_TYPE (section 2.2.1.1.23)</a></span>
enumeration. If it does, return ERROR_DHCP_POLICY_FQDN_RANGE_UNSUPPORTED<a id="Appendix_A_Target_87"></a><a aria-label="Product behavior note 87" href="afab0546-79ae-4764-8dab-27a85cca5145#Appendix_A_87" data-linktype="relative-path">&lt;87&gt;</a></p>
</li><li><p><span><span> 
</span></span>Retrieve the <b>DHCPv4Scope</b> ADM element entry corresponding
to the <i>SubnetAddress</i> parameter from the server ADM element <b>DHCPv4ScopesList</b>.
If the <b>DHCPv4Scope</b> ADM element entry is not present, return
ERROR_DHCP_SUBNET_NOT_PRESENT.</p>
</li><li><p><span><span> 
</span></span>Retrieve the <b>DHCPv4Scope.DHCPv4ScopePolicyList</b> ADM element
from the <b>DHCPv4Scope</b> ADM element entry. Retrieve the <b>DHCPv4Policy</b>
ADM element entry from the <b>DHCPv4ScopePolicyList</b> ADM element
corresponding to the specified <i>PolicyName</i> parameter. If there is no <b>DHCPv4Policy</b>
ADM element that has the specified <i>PolicyName</i> parameter, return
ERROR_DHCP_POLICY_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>Retrieve the <b>DHCPv4Scope.DHCPv4ScopeIPRangesList</b> ADM
element. Check whether the <i>Range</i> parameter specified is within at least
one of the <b>DHCPv4IPRange</b> ADM elements in the <b>DHCPv4Scope.DHCPv4ScopeIPRangesList</b>
ADM element. Return ERROR_DHCP_POLICY_RANGE_BAD if this check fails.</p>
</li><li><p><span><span> 
</span></span>Retrieve the <b>DHCPv4Policy.Policy.Ranges</b> ADM element. Check
whether the range specified overlaps any of the <b>DHCP_IP_RANGE</b> ADM elements
in the <b>DHCPv4Policy.Policy.Ranges</b> ADM element. Return
ERROR_DHCP_POLICY_RANGE_EXISTS if the check succeeds.</p>
</li><li><p><span><span> 
</span></span>Create a <b>DHCP_IP_RANGE</b> ADM element with a <b>StartAddress</b>
member and an <b>EndAddress</b> member within the <i>Range</i> parameter. Add
the <b>DHCP_IP_RANGE</b> ADM element created to the end of the <b>DHCPv4Policy.Policy.Ranges</b>
ADM element, and return ERROR_SUCCESS.</p>
</li></ul><p><b>Exceptions Thrown:</b> No exceptions are thrown beyond
those thrown by the underlying RPC protocol <span><a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a></span>.</p></div>