<div class="content" name="R_DhcpV4GetOptionValue" uuid="f5bc4fa3-3273-48b0-a558-547834bcfe8c"><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 <a href="a7e5f2d1-04b7-4363-bdc0-76a1099664eb" data-linktype="relative-path">3</a>).</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 <a href="../ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2" data-linktype="relative-path">DWORD</a>
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>DHCP_FLAGS_OPTION_DEFAULT 0x00000000</td>
  <td>The option definition is set for the default vendor class.</td>
 </tr><tr>
  <td>DHCP_FLAGS_OPTION_IS_VENDOR 0x00000003</td>
  <td>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.</td>
 </tr></tbody></table>
</dd></dl><p><b>OptionID: </b>This is of type <b>DHCP_OPTION_ID</b>
data type (section <a href="4a0bb785-ceec-4f7a-b4a7-64555f6e0b62" data-linktype="relative-path">2.2.1.2.3</a>),
containing the <a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_da219357-8687-4b43-b32d-fafdf71af714" data-linktype="relative-path">option ID</a>
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 <a href="177415f4-85c1-4496-a414-4938dca18b93" data-linktype="relative-path">2.2.1.2.41</a>)
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 <a href="fa30c949-e063-4aea-b839-a6210e77741e" data-linktype="relative-path">2.2.1.2.42</a>)
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 <a href="c12007e1-f28d-43b2-9994-5c965f0e6bab" data-linktype="relative-path">3.3.1</a>.</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 <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.
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>0x00000000 ERROR_SUCCESS</td>
  <td>The call was successful.</td>
 </tr><tr>
  <td>0x00004E25 ERROR_DHCP_SUBNET_NOT_PRESENT</td>
  <td>The specified IPv4 subnet does not exist on the DHCP server.</td>
 </tr><tr>
  <td>0x00004E2A ERROR_DHCP_OPTION_NOT_PRESENT</td>
  <td>The specified option definition does not exist on the DHCP server database.</td>
 </tr><tr>
  <td>0x00004E4C ERROR_DHCP_CLASS_NOT_FOUND</td>
  <td>The class name being used is unknown or incorrect.</td>
 </tr><tr>
  <td>0x00004E8F ERROR_DHCP_POLICY_NOT_PRESENT</td>
  <td>The specified policy name does not exist.</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 <a href="38840bd0-0a5a-47ed-bc69-0dd870d33aec" data-linktype="relative-path">3.5.5</a>.
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 <a href="6c69e0bd-f280-46d9-93b4-054370c6428c" data-linktype="relative-path">3.1.1.11</a>).</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 <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p></div>