<div class="content"><p> </p><p>The <b>R_DhcpV4SetOptionValue</b> method sets the option
value for a <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_52323544-69e0-4172-8921-2711cbda988e" data-linktype="relative-path">policy</a></span> at the
specified level (<span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_128cd76b-eecb-41e6-96f7-f73c2bf9235a" data-linktype="relative-path">scope</a></span> or <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a></span>).</p><dl>
<dd>
<div><pre>  
 DWORD R_DhcpV4SetOptionValue(
     [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
     [in] DWORD Flags,
     [in] DHCP_OPTION_ID OptionID,
     [in, string, unique] WCHAR* PolicyName,
     [in, string, unique] WCHAR* VendorName,
     [in] LPDHCP_OPTION_SCOPE_INFO ScopeInfo,
     [in] LPDHCP_OPTION_DATA OptionValue
 );
</pre></div>
</dd></dl><p><b>ServerIpAddress: </b>The IP address/host name of
the DHCP server. This parameter is unused.</p><p><b>Flags: </b>This is of type <span><a href="../ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2" data-linktype="relative-path">DWORD</a></span>
that specifies that the option value is set for a specific or default vendor
class.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>DHCP_FLAGS_OPTION_DEFAULT</p>
  <p>0x00000000</p>
  </td>
  <td>
  <p>The <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_da9bfcf7-a7e0-4cf0-ac87-ffdd83a5f25b" data-linktype="relative-path">option definition</a></span>
  is set for the default vendor class.</p>
  </td>
 </tr><tr>
  <td>
  <p>DHCP_FLAGS_OPTION_IS_VENDOR</p>
  <p>0x00000003</p>
  </td>
  <td>
  <p>If a bitwise AND operation with this bitmask yields a
  nonzero value, it indicates that the option definition is set for a specific
  vendor class.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p><b>OptionId: </b>This is of type <b>DHCP_OPTION_ID</b>
data type (section <span><a href="4a0bb785-ceec-4f7a-b4a7-64555f6e0b62" data-linktype="relative-path">2.2.1.2.3</a></span>),
containing the <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_da219357-8687-4b43-b32d-fafdf71af714" data-linktype="relative-path">option ID</a></span> of the
option being set or modified.</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 <b>SubnetScopeInfo</b> member of the <i>ScopeInfo</i>
parameter for which the option value is being set.</p><p><b>VendorName: </b>A pointer to a null-terminated
Unicode string that contains the name of the vendor class for which the option
value is being set. This parameter is optional. If the vendor class is not
specified, the option value is set for the default vendor class.</p><p><b>ScopeInfo: </b>This is a pointer to a type <b>DHCP_OPTION_SCOPE_INFO</b>
structure (section <span><a href="177415f4-85c1-4496-a414-4938dca18b93" data-linktype="relative-path">2.2.1.2.41</a></span>) that
contains information describing the DHCPv4 scope for which this option value is
set. This value contains the server or scope level at which the option value is
to be set.</p><p><b>OptionValue: </b>A pointer to a type <b>DHCP_OPTION_DATA</b>
structure (section <span><a href="6b01abaa-f56b-4a9b-9596-64c7813fdfe7" data-linktype="relative-path">2.2.1.2.24</a></span>) that
contains the option value that is set for an option corresponding to the <i>OptionId</i>
parameter.</p><dl>
<dd>
<p>The method does not perform any checks to ensure
that the <i>OptionValue</i> parameter passed in is of the same <i>OptionType</i>
member value as that of the option corresponding to the <i>OptionId</i>
parameter passed in. It is the responsibility of the caller to ensure that the
correct <i>OptionType</i> member value is used for the <i>OptionValue</i>
parameter passed in. In case the <b>OptionType</b> member of the <i>OptionValue</i>
parameter passed in is different from that of the option corresponding to the <i>OptionId</i>
parameter, the behavior is undefined.</p>
</dd></dl><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 on the DHCP
  server.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E2A</p>
  <p>ERROR_DHCP_OPTION_NOT_PRESENT</p>
  </td>
  <td>
  <p>The specified option definition does not exist on the
  DHCP server database.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E4C</p>
  <p>ERROR_DHCP_CLASS_NOT_FOUND</p>
  </td>
  <td>
  <p>The class name being used is unknown or incorrect.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E8FL</p>
  <p>ERROR_DHCP_POLICY_NOT_FOUND</p>
  </td>
  <td>
  <p>The specified policy name does not exist.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004EA8L</p>
  <p>ERROR_DHCP_POLICY_FQDN_OPIION_UNSUPPORTED</p>
  </td>
  <td>
  <p>The option value cannot be specified because the
  policy contains an FQDN-based condition.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The opnum field value for this method is 101.</p><p>When processing this call, the DHCP server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>The <i>Flags</i> parameter MUST pass one of the validations given
in the <i>Flags</i> parameter description. Otherwise, the method returns
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the <b>ScopeType</b> member in the <i>ScopeInfo</i> parameter
is DhcpReservedOptions enumeration value or DhcpMScopeOptions enumeration value
and the <i>PolicyName</i> parameter is not NULL, the method returns
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>Validate whether this method is authorized for read/write 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 whether the policy specified in the <i>PolicyName</i>
parameter contains a condition of Type DhcpAttrFqdn or DhcpAttrFqdnSingleLabel,
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, and if the value of the <i>OptionId</i> parameter does
not specify DNS settings (81) or lease time (51), return
ERROR_DHCP_POLICY_FQDN_OPTION_UNSUPPORTED.<a id="Appendix_A_Target_73"></a><a aria-label="Product behavior note 73" href="afab0546-79ae-4764-8dab-27a85cca5145#Appendix_A_73" data-linktype="relative-path">&lt;73&gt;</a></p>
</li><li><p><span><span> 
</span></span>Validate the data pointed to by the input parameter <i>OptionValue</i>.
If the <b>Elements</b> member of the <b>DHCP_OPTION_DATA</b> structure is NULL
or the <b>NumElements</b> member is 0, return ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the <i>VendorName</i> parameter is not NULL, retrieve the <b>DHCPv4ClassDef</b>
ADM element entry corresponding to the <i>VendorName</i> parameter from the
server ADM element <b>DHCPv4ClassDefList</b>. If the <b>DHCPv4ClassDef</b> ADM
element entry is not found, return ERROR_DHCP_CLASS_NOT_FOUND. If <i>VendorName</i>
parameter is NULL, it refers to the default vendor class (see section <span><a href="6c69e0bd-f280-46d9-93b4-054370c6428c" data-linktype="relative-path">3.1.1.11</a></span>).</p>
</li><li><p><span><span> 
</span></span>If the <b>ScopeType</b> member in the <i>ScopeInfo</i> parameter
is DhcpDefaultOptions:</p>
<ul><li><p><span><span>  </span></span>Iterate
through the server ADM element <b>DHCPv4OptionDefList</b> and retrieve the <b>DHCPv4OptionDef.DHCPv4ClassedOptDefList</b>
ADM element corresponding to the vendor class specified by the <i>VendorName</i>
parameter. If there is no <b>DHCPv4OptionDef</b> ADM element entry corresponding
to the specified vendor class, return ERROR_DHCP_CLASS_NOT_FOUND.</p>
</li><li><p><span><span>  </span></span>Iterate
through the <b>DHCPv4ClassedOptDefList</b> ADM element, and if there is no <b>DHCPv4ClassedOptDef</b>
ADM element entry corresponding to the <i>OptionId</i> parameter, return
ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>Modify
the <b>DHCPv4ClassedOptDef</b> entry with the information in the <i>OptionValue</i>
parameter, and return ERROR_SUCCESS.</p>
</li></ul></li><li><p><span><span> 
</span></span>If the <b>ScopeType</b> member in the <i>ScopeInfo</i> parameter
contains DhcpGlobalOptions enumeration value:</p>
<ul><li><p><span><span>  </span></span>Retrieve
the server ADM element <b>DHCPv4ServerPolicyList</b>. Retrieve the <b>DHCPv4Policy</b>
ADM element from the <b>DHCPv4ServerPolicyList</b> ADM element that has the
same name as the <i>PolicyName</i> parameter. If there is no policy with the
specified name, return ERROR_DHCP_POLICY_NOT_FOUND.</p>
</li><li><p><span><span>  </span></span>Retrieve
each <b>DHCPv4PolicyOptionValue</b> ADM element from the server ADM element <b>DHCPv4ServerPolicyOptionValuesList</b>.
Get the <b>DHCPv4PolicyOptionValue</b> ADM element for which the <b>DHCPv4PolicyOptionValue.PolicyName</b>
ADM element and the <b>DHCPv4PolicyOptionValue.VendorName</b> ADM element match
the <i>PolicyName</i> parameter and the <i>VendorName</i> parameter passed to
the method.</p>
</li><li><p><span><span>  </span></span>From
the <b>DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues</b> ADM element list,
if there is a <b>DHCPv4ClassedOptValue</b> ADM element that contains the same <b>OptionID</b>
ADM element as the <i>OptionId</i> parameter passed to the method, delete the <b>DHCPv4ClassedOptValue</b>
ADM element.</p>
</li><li><p><span><span>  </span></span>Create
a <b>DHCPv4ClassedOptValue</b> ADM element with the <b>OptionID</b> ADM element
set to the <i>OptionId</i> parameter passed to the method and the data member
of the <b>DHCPv4ClassedOptValue</b> ADM element set to the <i>OptionValue</i>
parameter passed to the method.</p>
</li><li><p><span><span>  </span></span>Add
the created <b>DHCPv4ClassedOptValue</b> ADM element to the <b>DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues</b>
ADM element list, and return ERROR_SUCCESS.</p>
</li></ul></li><li><p><span><span> 
</span></span>If the <i>ScopeInfo</i> parameter contains the <b>SubnetScopeInfo</b>
member:</p>
<ul><li><p><span><span>  </span></span>Retrieve
the server ADM element <b>DHCPv4ScopesList</b>. Retrieve the <b>DHCPv4Scope</b>
ADM element that contains the same IP address as the IP address in the <b>SubnetScopeInfo</b>
member. If there is no scope with the specified IP address, return
ERROR_DHCP_SUBNET_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>Retrieve
the <b>DHCPv4Scope.DHCPv4ScopePolicyList</b> ADM element. Retrieve the <b>DHCPv4Policy</b>
ADM element from the <b>DHCPv4Scope.DHCPv4ScopePolicyList</b> ADM element with
the specified <b>PolicyName</b> ADM element. If there is no policy with the
specified name, return ERROR_DHCP_POLICY_NOT_FOUND.</p>
</li><li><p><span><span>  </span></span>Retrieve
each <b>DHCPv4PolicyOptionValue</b> ADM element from the <b>DHCPv4Scope</b> ADM
element <b>DHCPv4Scope.DHCPv4ScopePolicyOptionValuesList</b>. Get the <b>DHCPv4PolicyOptionValue</b>
ADM element for which the <b>DHCPv4PolicyOptionValue.PolicyName</b> ADM element
and the <b>DHCPv4PolicyOptionValue.VendorName</b> ADM element match the <i>PolicyName</i>
parameter and the <i>VendorName</i> parameter passed to the method.</p>
</li><li><p><span><span>  </span></span>From
the <b>DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues</b> ADM element list,
if there is a <b>DHCPv4ClassedOptValue</b> ADM element that contains the same <b>OptionID</b>
ADM element as the <i>OptionId</i> parameter passed to the method, delete the <b>DHCPv4ClassedOptValue</b>
ADM element.</p>
</li><li><p><span><span>  </span></span>Create
a <b>DHCPv4ClassedOptValue</b> ADM element with the <b>OptionID</b> ADM element
set to the <i>OptionId</i> parameter passed to the method and the data member
of the <b>DHCPv4ClassedOptValue</b> ADM element set to the <i>OptionValue</i>
parameter passed to the method.</p>
</li><li><p><span><span>  </span></span>Add
the created <b>DHCPv4ClassedOptValue</b> ADM element to the <b>DHCPv4PolicyOptionValue.DHCPv4ClassedOptionValues</b>
ADM element list, and return ERROR_SUCCESS.</p>
</li></ul></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>