<div class="content"><p> </p><p>The <b>R_DhcpSetOptionValueV5</b> method creates the option
value, when called for the first time. Otherwise, it modifies the option value
of a specific option on the DHCPv4 server for a specific user class and vendor
class. <i>ScopeInfo</i> defines the scope on which this option value is set. If
the user class or vendor class is not provided, a default user class or vendor
class is taken.</p><dl>
<dd>
<div><pre> DWORD R_DhcpSetOptionValueV5(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DWORD Flags,
   [in] DHCP_OPTION_ID OptionId,
   [in, string, unique] WCHAR* ClassName,
   [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>Option definition 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 <span><a href="4a0bb785-ceec-4f7a-b4a7-64555f6e0b62" data-linktype="relative-path">DHCP_OPTION_ID (section 2.2.1.2.3)</a></span>,
containing the option identifier of the option being set or modified.</p><p><b>ClassName: </b>A pointer to a null-terminated
Unicode string that contains the name of the user class to which the option
value is being set. This parameter is optional. If the <i>ClassName</i>
parameter is not specified, the option value is set for the default user class.</p><p><b>VendorName: </b>A pointer to a null-terminated
Unicode string that contains the name of the vendor class to which the option
value is being set. This parameter is optional. If the vendor class is not
specified, the option value is set for a default vendor class.</p><p><b>ScopeInfo: </b>This is a pointer to a <span><a href="177415f4-85c1-4496-a414-4938dca18b93" data-linktype="relative-path">DHCP_OPTION_SCOPE_INFO (section 2.2.1.2.41)</a></span>
structure that contains information describing the DHCPv4 scope this option
value is set on. This value contains the level (that is, default, server,
scope, multicast scope, or IPv4 reservation level) at which the option values
are set.</p><p><b>OptionValue: </b>A pointer to <span><a href="6b01abaa-f56b-4a9b-9596-64c7813fdfe7" data-linktype="relative-path">DHCP_OPTION_DATA (section 2.2.1.2.24)</a></span>
structure that contains the option value that is set for an option
corresponding to the <i>OptionId</i>. For Dynamic DNS update settings, see
section <span><a href="c12007e1-f28d-43b2-9994-5c965f0e6bab" data-linktype="relative-path">3.3.1</a></span>.</p><p>The method does not perform any checks to ensure that
the <i>OptionValue</i> passed in is of the same <b>OptionType</b> as that of
the option corresponding to the <i>OptionId</i> passed in. It is the
responsibility of the caller to ensure that the correct <b>OptionType</b> is
used for the <i>OptionValue</i> passed in. In case the <b>OptionType</b> of the
<i>OptionValue</i> passed in is different from that of the option corresponding
to the <i>OptionId</i>, the behavior is undefined.</p><p><b>Return Values: </b>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 <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 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>0x00004E32</p>
  <p>ERROR_DHCP_NOT_RESERVED_CLIENT</p>
  </td>
  <td>
  <p>The specified DHCP client is not a reserved client.</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></tbody></table>
</dd></dl><p>The opnum field value for this method is 19.</p><p>When processing this call, the DHCP server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>Validate if this method is authorized for read/write access per
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>The <i>Flags</i> parameter MUST pass one of the validations given
in the <i>Flags</i> field description. Otherwise, the method returns
ERROR_INVALID_PARAMETER.</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 DHCP_OPTION_DATA structure is NULL or the <b>NumElements</b>
member is 0, return ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If <i>ClassName</i> is not NULL, retrieve the <b>DHCPv4ClassDef</b>
entry corresponding to the <i>ClassName</i> from the server ADM element <b>DHCPv4ClassDefList</b>.
If the <b>DHCPv4ClassDef</b> entry is not found, return
ERROR_DHCP_CLASS_NOT_FOUND. If <i>ClassName</i> 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 <i>VendorName</i> is not NULL, retrieve the <b>DHCPv4ClassDef</b>
entry corresponding to the <i>VendorName</i> from the server ADM element <b>DHCPv4ClassDefList</b>.
If the <b>DHCPv4ClassDef</b> entry is not found, return
ERROR_DHCP_CLASS_NOT_FOUND. If <i>VendorName</i> is NULL, it refers to the
default vendor class (see section 3.1.1.11).</p>
</li><li><p><span><span> 
</span></span>Iterate through the server ADM element <b>DHCPv4OptionDefList</b>
and retrieve <b>DHCPv4OptionDef.DHCPv4ClassedOptDefList</b> corresponding to
the user and vendor class specified by <i>ClassName</i> and <i>VendorName</i>
respectively. If <i>ClassName</i> or <i>VendorName</i> is NULL, it refers to
the default user class or vendor class respectively, as specified in section <span><a href="4aa40625-0f9f-4e89-93a4-e4455bc1cc95" data-linktype="relative-path">3.1.1.9</a></span>.
If there is no <b>DHCPv4OptionDef</b> entry corresponding to the specified user
and vendor classes, return ERROR_DHCP_CLASS_NOT_FOUND. Iterate through the <b>DHCPv4ClassedOptDefList</b>
and if there is no <b>DHCPv4ClassedOptDef</b> entry corresponding to <i>OptionId</i>,
return ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpDefaultOptions and if there is
no <b>DHCPv4ClassedOptDef</b> entry corresponding to <i>OptionId</i> in the
retrieved <b>DHCPv4ClassedOptDef</b>, return ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpDefaultOptions, modify the <b>DHCPv4ClassedOptDef</b>
entry with information in <i>OptionValue</i>, and return ERROR_SUCCESS.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpGlobalOptions, iterate through
the server ADM element <b>DHCPv4ServerOptValueList</b> and retrieve <b>DHCPv4OptionValue</b>
corresponding to the user and vendor class specified by <i>ClassName</i> and <i>VendorName</i>
respectively. If <i>ClassName</i> or <i>VendorName</i> is NULL, it refers to
the default user class or vendor class respectively, as specified in section
3.1.1.9. If the <b>DHCPv4OptionValue</b> entry is not found, return ERROR_DHCP_CLASS_NOT_FOUND.
Retrieve the <b>DHCPv4ClassedOptValue</b> entry corresponding to the <i>OptionId</i>
from <b>DHCPv4OptionValue.DHCPv4ClassedOptValueList</b>. If the <b>DHCPv4ClassedOptValue</b>
entry is not found, return ERROR_DHCP_OPTION_NOT_PRESENT. Modify the <b>Value</b>
member of retrieved <b>DHCPv4ClassedOptValue</b> with information in <i>OptionValue</i>,
and return ERROR_SUCCESS.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpSubnetOptions, retrieve the <b>DHCPv4Scope</b>
entry corresponding to <i>ScopeInfo</i> from the server ADM element <b>DHCPv4ScopesList</b>.
If the <b>DHCPv4Scope</b> ADM element is not found, return
ERROR_DHCP_SUBNET_NOT_PRESENT. Iterate through <b>DHCPv4Scope.DHCPv4ScopeOptValuesList</b>
and retrieve <b>DHCPv4OptionValue</b> corresponding to the user and vendor
class specified by <i>ClassName</i> and <i>VendorName</i> respectively. If <i>ClassName</i>
or <i>VendorName</i> is NULL, it refers to the default user class or vendor
class respectively, as specified in section 3.1.1.9. If the <b>DHCPv4OptionValue</b>
entry is not found, return ERROR_DHCP_CLASS_NOT_FOUND. Retrieve the <b>DHCPv4ClassedOptValue</b>
entry corresponding to <i>OptionId</i> from <b>DHCPv4OptionValue.DHCPv4ClassedOptValueList</b>.
If the <b>DHCPv4ClassedOptValue</b> entry is not found, return
ERROR_DHCP_OPTION_NOT_PRESENT. Modify the <b>Value</b> member of retrieved <b>DHCPv4ClassedOptValue</b>
with information in <i>OptionValue</i>, and return ERROR_SUCCESS.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpReservedOptions, retrieve the <b>DHCPv4Scope</b>
entry from the server ADM element <b>DHCPv4ScopesList</b> that contains the <b>ReservedIpAddress</b>
field of the <i>ScopeInfo</i> parameter. If the <b>DHCPv4Scope</b> entry is not
found, return ERROR_FILE_NOT_FOUND. Retrieve the <b>DHCPv4Reservation</b> entry
from <b>DHCPv4Scope.DHCPv4ReservationsList</b> corresponding to <b>ReservedIpAddress</b>.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpReservedOptions, and if the <b>ReservedIpAddress</b>
is not part of any of the <b>DHCPv4Scope</b>, or if there is no <b>DHCPv4Reservation</b>
corresponding to <b>ReservedIpAddress</b>, return
ERROR_DHCP_NOT_RESERVED_CLIENT.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpReservedOptions, and if the <b>DHCPv4Scope</b>
entry is found and if the <b>ScopeInfo.SubnetAddress</b>  does not match with <i>ScopeInfo&#39;s
</i><b>ReservedIpSubnetAddress</b> field, then return
ERROR_DHCP_SUBNET_NOT_PRESENT.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpReservedOptions, iterate through
<b>DHCPv4Reservation.DHCPv4ResvOptValuesList</b> and retrieve <b>DHCPv4OptionValue</b>
corresponding to the user and vendor class specified by <i>ClassName</i> and <i>VendorName</i>
respectively. If <i>ClassName</i> or <i>VendorName</i> is NULL, it refers to
the default user class or vendor class respectively, as specified in section
3.1.1.9. If the <b>DHCPv4OptionValue</b> entry is not found, return
ERROR_DHCP_CLASS_NOT_FOUND. Retrieve the <b>DHCPv4ClassedOptValue</b> entry
corresponding to <i>OptionId</i> from the <b>DHCPv4OptionValue.DHCPv4ClassedOptValueList</b>.
If the <b>DHCPv4ClassedOptValue</b> entry is not found, return
ERROR_DHCP_OPTION_NOT_PRESENT. Modify the <b>Value</b> member of retrieved <b>DHCPv4ClassedOptValue</b>
with information in <i>OptionValue</i>, and return ERROR_SUCCESS.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpMScopeOptions, retrieve the <b>DHCPv4MScope</b>
entry corresponding to the <i>ScopeInfo</i> parameter from the server ADM
element <b>DHCPv4MScopesList</b>. If the <b>DHCPv4MScope</b> entry is not found,
return ERROR_FILE_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>If <i>ScopeInfo</i> contains DhcpMScopeOptions, iterate through <b>DHCPv4MScope.DHCPv4MScopeOptValuesList</b>
and retrieve <b>DHCPv4OptionValue</b> corresponding to the user and vendor
class specified by <i>ClassName</i> and <i>VendorName</i> respectively. If <i>ClassName</i>
or <i>VendorName</i> is NULL, it refers to the default user class or vendor
class respectively, as specified in section 3.1.1.9. If the <b>DHCPv4OptionValue</b>
entry is not found, return ERROR_DHCP_CLASS_NOT_FOUND. Retrieve the <b>DHCPv4ClassedOptValue</b>
entry corresponding to <i>OptionId</i> from <b>DHCPv4OptionValue.DHCPv4ClassedOptValueList</b>.
If the <b>DHCPv4ClassedOptValue</b> entry is not found, return
ERROR_DHCP_OPTION_NOT_PRESENT. Modify the <b>Value</b> member of retrieved <b>DHCPv4ClassedOptValue</b>
with information in <i>OptionValue</i>, 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>