<div class="content" name="R_DhcpCreateOptionV5" uuid="589d0537-21a4-4a14-a380-99654e5c197a"><p>The <b>R_DhcpCreateOptionV5</b> method creates an option
definition of a specific option for a specific user class and vendor class at
the default option level. The <i>OptionId</i> specifies the identifier of the
option. If the user class or vendor class is not defined, the option definition
is created for the default user class and vendor class.</p><dl>
<dd>
<div><pre> DWORD R_DhcpCreateOptionV5(
   [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 OptionInfo
 );
</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 definition is created 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>Option definition is created 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 created for a specific vendor class.</td>
 </tr></tbody></table>
</dd></dl><p><b>OptionId: </b>This is of type <a href="4a0bb785-ceec-4f7a-b4a7-64555f6e0b62" data-linktype="relative-path">DHCP_OPTION_ID (section 2.2.1.2.3)</a>,
containing the option identifier for the option being created.</p><p><b>ClassName: </b>A pointer to a null-terminated
Unicode string that contains the name of the user class for which the option
definition is created. This parameter is optional. If the <i>ClassName</i>
parameter is not specified, the option definition is created 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 for which the option
definition is created. This parameter is optional, and if the vendor class name
is not specified, the option definition is created for the default vendor
class.</p><p><b>OptionInfo: </b>This is a pointer to a <a href="855b6a9a-e6e4-4c9d-a732-aadad749ca03" data-linktype="relative-path">DHCP_OPTION (section 2.2.1.2.25)</a>
structure that contains the information about the option definition.</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 <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 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>0x00004E29 ERROR_DHCP_OPTION_EXITS</td>
  <td>The specified option definition already exists on DHCP server database.</td>
 </tr><tr>
  <td>0x00004E2D ERROR_DHCP_JET_ERROR</td>
  <td>An error occurred while accessing 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></tbody></table>
</dd></dl><p>The opnum field value for this method is 14.</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 <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>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>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 user class (see section <a href="4aa40625-0f9f-4e89-93a4-e4455bc1cc95" data-linktype="relative-path">3.1.1.9</a>).</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.9).</p>
</li><li><p><span><span> 
</span></span>Validate the <b>DefaultValue</b> data structure, pointed to by
the <i>OptionInfo</i> parameter, by checking that its <b>Elements</b> member is
not NULL and that its <b>NumElements</b> member is not zero. If either check
fails, return ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>Iterate through the server ADM element <b>DHCPv4OptionDefList</b>
and retrieve the <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
3.1.1.9. If there is no <b>DHCPv4OptionDef</b> entry corresponding to specified
user and vendor classes, return ERROR_DHCP_CLASS_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>Iterate through <b>DHCPv4ClassedOptDefList</b> and if there is
any <b>DHCPv4ClassedOptDef</b> entry corresponding to <i>OptionId</i>, return ERROR_DHCP_OPTION_EXITS.</p>
</li><li><p><span><span> 
</span></span>Create a <b>DHCPv4ClassedOptDef</b> object and insert it into <b>DHCPv4ClassedOptDefList</b>.
The <b>DHCPv4ClassedOptDef</b> object is initialized with information in the <i>OptionInfo</i>
input parameter.</p>
</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 specified in <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p></div>