<div class="content"><p> </p><p>The <b>R_DhcpCreateOption</b> method creates an option
definition of the specified option for the default <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_713c7395-9431-4d67-bab1-a069ae7461e2" data-linktype="relative-path">user class</a></span> and <span><a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_45d20b00-7166-4f94-b679-4cc5a7835a3a" data-linktype="relative-path">vendor
class</a></span> pair at the default option level. The <i>OptionID</i>
parameter specifies the identifier of the option.</p><dl>
<dd>
<div><pre> DWORD R_DhcpCreateOption(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_OPTION_ID OptionID,
   [in, ref] 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>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 for the option being created.</p><p><b>OptionInfo: </b>This is a pointer to a <span><a href="855b6a9a-e6e4-4c9d-a732-aadad749ca03" data-linktype="relative-path">DHCP_OPTION (section 2.2.1.2.25)</a></span>
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 <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>0x00004E29</p>
  <p>ERROR_DHCP_OPTION_EXITS</p>
  </td>
  <td>
  <p>The specified option already exists on the DHCP server
  database.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00004E2D</p>
  <p>ERROR_DHCP_JET_ERROR</p>
  </td>
  <td>
  <p>An error occurred while accessing the DHCP server
  database.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The opnum field value for this method is 8.</p><p>When processing this call, the DHCP server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>Validate whether 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 the error ERROR_ACCESS_DENIED.</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 though the server Abstract Data Model (ADM) element <b>DHCPv4OptionDefList</b>,
and retrieve the <b>DHCPv4ClassedOptDefList</b> ADM element corresponding to
the <b>DHCPv4OptionDef</b> ADM element entry whose <b>UserClass</b> and <b>VendorClass</b>
ADM element fields are NULL. If there is no <b>DHCPv4OptionDef</b> ADM element
entry whose <b>UserClass</b> and <b>VendorClass</b> fields are NULL, return
ERROR_DHCP_CLASS_NOT_FOUND.</p>
</li><li><p><span><span> 
</span></span>Iterate through the <b>DHCPv4ClassedOptDefList</b> ADM element;
if there is any <b>DHCPv4ClassedOptDef</b> ADM element entry corresponding to
that specific <i>OptionID</i> parameter, return the error
ERROR_DHCP_OPTION_EXITS.</p>
</li><li><p><span><span> 
</span></span>Create a <b>DHCPv4ClassedOptDef</b> ADM element object, and
insert it into the <b>DHCPv4ClassedOptDefList</b> ADM element. The <b>DHCPv4ClassedOptDef</b>
ADM element 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 <span><a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a></span>.</p></div>