<div class="content"><p> </p><p>The <b>R_DhcpV4GetOptionValue</b> method gets the option
value for the specified <i>PolicyName</i> parameter and <i>OptionID</i>
parameter. The memory for the <i>OptionValue</i> parameter is allocated by this
method and can be freed by the caller by calling the function <b>midl_user_free</b>
(section <span><a href="a7e5f2d1-04b7-4363-bdc0-76a1099664eb" data-linktype="relative-path">3</a></span>).</p><dl>
<dd>
<div><pre> DWORD R_DhcpV4GetOptionValue(
   [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,
   [out] LPDHCP_OPTION_VALUE* 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 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 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 values
are set.</p><p><b>OptionValue: </b>A pointer of type <b>LPDHCP_OPTION_VALUE</b>
(section <span><a href="fa30c949-e063-4aea-b839-a6210e77741e" data-linktype="relative-path">2.2.1.2.42</a></span>) that
contains the option value that is set for an option corresponding to the <i>OptionId</i>
parameter. 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><dl>
<dd>
<p>The method does not perform any checks to ensure
that the <i>OptionValue</i> parameter passed in is of the same <b>OptionType</b>
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 <b>OptionType</b> member value is used for the <i>OptionValue</i>
parameter passed in. In case the <b>OptionType</b> member value 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>0x00004E8F</p>
  <p>ERROR_DHCP_POLICY_NOT_PRESENT</p>
  </td>
  <td>
  <p>The specified policy name does not exist.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The opnum field value for this method is 103.</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 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 the <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 set to DhcpDefaultOptions:</p>
<ul><li><p><span><span>  </span></span>Iterate
through the <b>DHCPv4OptionDefList</b> server ADM element and retrieve the <b>DHCPv4OptionDef.DHCPv4ClassedOptDefList</b>
corresponding to the default user class and vendor class specified by the <i>VendorName</i>
parameter.</p>
</li><li><p><span><span>  </span></span>If
there is no <b>DHCPv4OptionDef.DHCPv4ClassedOptDefList</b> entry corresponding
to this set of user and vendor classes, return ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>If
there is no <b>DHCPv4ClassedOptDef</b> entry in <b>DHCPv4ClassedOptDefList</b>
corresponding to <b>OptionID</b>, return ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>Copy
the information in <b>DHCPv4ClassedOptDef</b> into the <i>OptionValue</i>
parameter and return it to the caller.</p>
</li></ul></li><li><p><span><span> 
</span></span>If the <b>ScopeType</b> member in the <i>ScopeInfo</i> parameter
contains the 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 no <b>DHCPv4ClassedOptValue</b> ADM element that contains the same <b>OptionID</b>
ADM element as the <i>OptionId</i> parameter, return
ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>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, allocate
memory for a <b>DHCP_OPTION_VALUE</b> structure and populate the structure with
the <b>OptionID</b> ADM element and <b>Value</b> ADM element in the <b>DHCPv4ClassedOptValue</b>
ADM element. Return ERROR_SUCCESS.</p>
</li></ul></li><li><p><span><span> 
</span></span>If the <b>ScopeType</b> member of the <i>ScopeInfo</i> parameter
contains the <b>SubnetScopeInfo</b> enumeration value:</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 <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 scope 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 no <b>DHCPv4ClassedOptValue</b> ADM element that contains the same <b>OptionID</b>
ADM element as the <i>OptionId</i> parameter, return
ERROR_DHCP_OPTION_NOT_PRESENT.</p>
</li><li><p><span><span>  </span></span>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, allocate
memory for a <b>DHCP_OPTION_VALUE</b> structure and populate the structure with
the <b>OptionID</b> ADM element and the <b>Value</b> ADM element in the <b>DHCPv4ClassedOptValue</b>
ADM element.</p>
</li></ul></li><li><p><span><span> 
</span></span>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>