<div class="content" name="R_DhcpServerSetConfig" uuid="82b105f2-14f6-4adf-87f9-8595abde8f2f"><p>The <b>R_DhcpServerSetConfig</b> method sets/modifies the
DHCPv4 server settings. There is an extension method <a href="b8a33c5c-c04d-429a-8906-5fb5d22b1f68" data-linktype="relative-path">R_DhcpServerSetConfigV4 (section 3.1.4.40)</a>
that sets some additional settings on the DHCPv4 server.</p><dl>
<dd>
<div><pre> DWORD R_DhcpServerSetConfig(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DWORD FieldsToSet,
   [in, ref] LPDHCP_SERVER_CONFIG_INFO ConfigInfo
 );
</pre></div>
</dd></dl><p><b>ServerIpAddress: </b>The IP address/host name of
the DHCP server. This parameter is unused.</p><p><b>FieldsToSet: </b>A <a href="../ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2" data-linktype="relative-path">DWORD</a>
that contains the bitmask of the fields in the <i>ConfigInfo</i> structure to
set. This method can be called with a value for <i>FieldsToSet</i>. </p><dl>
<dd>
<p>The bit mapping for the various values for <i>FieldsToSet</i>
is listed in the following table:</p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>FieldsToSet</p>
   </th>
   <th>
   <p>Bit</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>Set_APIProtocolSupport</td>
  <td>0x00000001</td>
 </tr><tr>
  <td>Set_DatabaseName</td>
  <td>0x00000002</td>
 </tr><tr>
  <td>Set_DatabasePath</td>
  <td>0x00000004</td>
 </tr><tr>
  <td>Set_BackupPath</td>
  <td>0x00000008</td>
 </tr><tr>
  <td>Set_BackupInterval</td>
  <td>0x00000010</td>
 </tr><tr>
  <td>Set_DatabaseLoggingFlag</td>
  <td>0x00000020</td>
 </tr><tr>
  <td>Set_RestoreFlag</td>
  <td>0x00000040</td>
 </tr><tr>
  <td>Set_DatabaseCleanupInterval</td>
  <td>0x00000080</td>
 </tr><tr>
  <td>Set_DebugFlag</td>
  <td>0x00000100</td>
 </tr></tbody></table>
</dd>
<dd>
<p>The DHCP Server ignores the bits not specified in
the table.</p>
</dd>
<dd>
<p>Most of the settings are effective immediately. The
DHCPv4 server needs to be restarted for the following settings to become
effective:</p>
</dd></dl><ul><li><p><span><span> 
</span></span><i>Set_APIProtocolSupport</i></p>
</li><li><p><span><span> 
</span></span><i>Set_DatabaseName</i></p>
</li><li><p><span><span> 
</span></span><i>Set_DatabasePath</i></p>
</li><li><p><span><span> 
</span></span><i>Set_DatabaseLoggingFlag</i></p>
</li><li><p><span><span> 
</span></span><i>Set_RestoreFlag</i></p>
</li></ul><p><b>ConfigInfo: </b>A pointer of type <a href="62b738d8-c898-4d6c-9136-5269d60e05d6" data-linktype="relative-path">DHCP_SERVER_CONFIG_INFO (section 2.2.1.2.53)</a>
structure that contains the settings for the DHCPv4 server. The value that is
passed here depends on the <i>FieldsToSet</i> parameter. Details of the
dependencies follow the return value description.</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. Otherwise, the return
value 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></tbody></table>
</dd></dl><p>The opnum field value for this method is 25.</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 the error ERROR_ACCESS_DENIED.</p>
</li><li><p><span><span> 
</span></span>Validate the <i>FieldsToSet</i> parameter for nonzero. If it is
zero, return ERROR_SUCCESS.</p>
</li><li><p><span><span> 
</span></span>If the <i>Set_APIProtocolSupport</i> bit is set in the <i>FieldsToSet</i>
parameter and the <b>APIProtocolSupport</b> member in the <i>ConfigInfo</i>
parameter is set to zero, then return ERROR_INVALID_PARAMETER. Else if the <i>Set_APIProtocolSupport</i>
bit is set in the <i>FieldsToSet</i> parameter, then set/modify the <b>APIProtocolSupport</b>
member from <i>ConfigInfo</i> to the server Abstract Data Model (ADM) element <b>DHCPv4ServerConfigInfo</b>.
If the <b>APIProtocolSupport</b> member is set to values other than 1, 2, 4, or
7, the DHCP Server behavior is undefined.</p>
</li><li><p><span><span> 
</span></span>If the <i>Set_DatabaseName</i> bit is set in the <i>FieldsToSet</i>
parameter and the <b>DatabaseName</b> member in the <i>ConfigInfo</i> parameter
is NULL or is a NULL terminated empty string, then return
ERROR_INVALID_PARAMETER. Else if the <i>Set_DatabaseName</i> bit is set in <i>FieldsToSet</i>
and the <b>DatabaseName</b> member cannot be converted into an <a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_3e74a21f-5f75-42f3-9649-b68d9fab18a1" data-linktype="relative-path">OEM</a> or <a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_100cd8a6-5cb1-4895-9de6-e4a3c224a583" data-linktype="relative-path">ANSI</a> character string, then
return ERROR_INVALID_NAME. Else if the <i>Set_DatabaseName</i> bit is set in <i>FieldsToSet</i>,
then set/modify the <b>DatabaseName</b> member from the <i>ConfigInfo</i>
parameter to the <b>DHCPv4ServerConfigInfo</b> ADM element object.</p>
</li><li><p><span><span> 
</span></span>If the <i>Set_DatabasePath</i> bit is set in <i>FieldsToSet</i>
and the <b>DatabasePath</b> member in <i>ConfigInfo</i> is NULL or is a NULL
terminated empty string, then return ERROR_INVALID_PARAMETER. Else if the <i>Set_DatabasePath</i>
bit is set in <i>FieldsToSet</i> and the <b>DatabasePath</b> member cannot be
converted into OEM or ANSI character string, then return ERROR_INVALID_NAME.
Else if the <i>Set_DatabasePath</i> bit is set in <i>FieldsToSet</i>, then
create the directory with the specified path and set/modify the <b>DatabasePath</b>
member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b> ADM element
object.</p>
</li><li><p><span><span> 
</span></span>If the <i>Set_BackupPath </i>bit is set in the <i>FieldsToSet</i>
parameter and the <b>BackupPath</b> member in <i>ConfigInfo</i> is NULL or is a
NULL terminated empty string, then return ERROR_INVALID_PARAMETER. Else if the <i>Set_BackupPath</i>
bit is set in <i>FieldsToSet</i> and the <b>BackupPath</b> member cannot be
converted into an OEM or ANSI character string, then return ERROR_INVALID_NAME.
Else if the <i>Set_BackupPath</i> bit is set in <i>FieldsToSet</i>, then create
the directory with the specified path and set/modify the <b>BackupPath</b>
member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b> ADM element
object.</p>
</li><li><p><span><span> 
</span></span>If <i>Set_BackupInterval</i> is set in <i>FieldsToSet</i> and the
<b>BackupInterval</b> member is zero, return ERROR_INVALID_PARAMETER. Else if <i>Set_BackupInterval</i>
is set in <i>FieldsToSet</i> and the <b>BackupInterval</b> member (in minutes)
after converting to milliseconds is greater than 0xFFFFFFFF, return
ERROR_ARITHMETIC_OVERFLOW. Else if <i>Set_BackupInterval</i> is set in <i>FieldsToSet</i>,
then set/modify the <b>BackupInterval</b> member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b>
ADM element object.</p>
</li><li><p><span><span> 
</span></span>If <i>Set_DatabaseLoggingFlag </i>is set in <i>FieldsToSet</i>,
set/modify the <b>DatabaseLoggingFlag</b> member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b>
ADM element object.</p>
</li><li><p><span><span> 
</span></span>If <i>Set_RestoreFlag</i> is set in <i>FieldsToSet</i>,
set/modify <b>RestoreFlag</b> member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b>
ADM element object.</p>
</li><li><p><span><span> 
</span></span>If <i>Set_DatabaseCleanupInterval </i>is set in <i>FieldsToSet</i>
and the <b>DatabaseCleanupInterval</b> member is zero, return
ERROR_INVALID_PARAMETER. Else if <i>Set_DatabaseCleanupInterval</i> is set in <i>FieldsToSet</i>
and the <b>DatabaseCleanupInterval</b> member (in minutes) after converting to
milliseconds is greater than 0xFFFFFFFF, return ERROR_ARITHMETIC_OVERFLOW. Else
if <i>Set_DatabaseCleanupInterval</i> is set in <i>FieldsToSet</i>, then
set/modify the <b>DatabaseCleanupInterval</b> member from <i>ConfigInfo</i> to
the <b>DHCPv4ServerConfigInfo</b> ADM element object.</p>
</li><li><p><span><span> 
</span></span>If <i>Set_DebugFlag </i>is set in <i>FieldsToSet</i>, set/modify
the <b>DebugFlag</b> member from <i>ConfigInfo</i> to the <b>DHCPv4ServerConfigInfo</b>
ADM element object.</p>
</li><li><p><span><span> 
</span></span>Return ERROR_SUCCESS to the caller.</p>
</li></ul><p><b>Exceptions Thrown:</b> No exceptions SHOULD be 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>