<div class="content" name="DsRolerGetPrimaryDomainInformation" uuid="7f422081-32e8-446e-b41c-ed5e72417ae5"><p>The DsRolerGetPrimaryDomainInformation (Opnum 0) method
returns the requested information about the current configuration or state of
the computer on which the server is running.</p><dl>
<dd>
<div><pre> DWORD DsRolerGetPrimaryDomainInformation(
   [in] handle_t hBinding,
   [in] DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
   [out, switch_is(InfoLevel)] PDSROLER_PRIMARY_DOMAIN_INFORMATION* DomainInfo
 );
</pre></div>
</dd></dl><p><b>hBinding: </b>An <a href="../ms-dtyp/d0dffa33-812f-4214-a987-4ee149328eec" data-linktype="relative-path">RPC binding
handle</a>, as specified in <a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a> section 2.3.1.</p><p><b>InfoLevel: </b>The type of data requested by the
client. For possible values in this enumeration, see section <a href="1eeb0122-c491-4e30-a6bd-f6c3b38f0769" data-linktype="relative-path">2.2.7</a>.</p><p><b>DomainInfo: </b>The requested information that the
server provides to the client. The value of the <i>InfoLevel</i> parameter
indicates the type of information that is requested; information is returned in
the corresponding member of the <a href="e89f48b9-02a7-4378-b21a-6475bdbea6ef" data-linktype="relative-path">DSROLER_PRIMARY_DOMAIN_INFORMATION</a>
union.</p><p><b>Return Values: </b>The method returns 0 if
successful; if failed, it returns a nonzero error code as specified in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.
Specifically, in addition to any other error codes, the server MUST return the
following error codes for the following error conditions. Any other values
transmitted in this field are implementation-specific. All nonzero values MUST
be treated the same for protocol purposes.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000057 ERROR_INVALID_PARAMETER</td>
  <td>One or more parameters are invalid.</td>
 </tr><tr>
  <td>0x00000008 ERROR_NOT_ENOUGH_MEMORY</td>
  <td>A memory allocation failure occurred.</td>
 </tr></tbody></table>
</dd></dl><p>This method obtains the identity and authorization
information about the client from the underlying <a href="4339df3c-494b-49b4-9c60-d25526a35a0d#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> runtime. Servers that
implement this method SHOULD impose an authorization policy decision before
performing the function.<a id="Appendix_A_Target_13"></a><a aria-label="Product behavior note 13" href="9eaff666-129a-486e-ba94-1193d51f5a5b#Appendix_A_13" data-linktype="relative-path">&lt;13&gt;</a></p><p>The server determines the appropriate response to the
request by examining the <i>InfoLevel</i> parameter, setting the appropriate
fields in the <i>DomainInfo</i> parameter and sending the response to the
caller.</p><p>The following describes which fields are used and what the
fields contain for each <i>InfoLevel</i> value.</p><p><b>DsRolePrimaryDomainInfoBasic</b></p><p>When the <i>InfoLevel</i> is <b>DsRolePrimaryDomainInfoBasic</b>,
the server MUST use the <b>DomainInfoBasic</b> field of the <i>DomainInfo</i>
parameter, whose type is <a href="cd1458c4-b50b-4535-a16c-020980a61d27" data-linktype="relative-path">DSROLER_PRIMARY_DOMAIN_INFO_BASIC</a>.
The result MUST be constructed in the following manner:</p><ol><li><p><span>    </span>Determine the
role of the server and set the <b>MachineRole</b> field of <b>DomainInfoBasic</b>
according to the ComputerRole state element. If the server ComputerRole state
element indicates that it is not a stand-alone computer, set the <b>DomainNameFlat</b>,
<b>DomainNameDns</b>, <b>DomainForestName</b>, and <b>DomainGuid</b> fields of
the DomainInfoBasic structure according to the NetBIOSDomainName,
DNSDomainName, ForestName, and DomainGUID state information. If the DomainGUID
state element is non-empty, the DSROLE_PRIMARY_DOMAIN_GUID_PRESENT bit MUST be
set in the <b>Flags</b> member of DomainInfoBasic.</p>
</li><li><p><span>    </span>If the server is
a stand-alone computer, set the <b>DomainNameFlat</b> field of DomainInfoBasic
according to NetBIOSDomainName state information; and then set the other fields
to NULL.</p>
</li><li><p><span>    </span>If the server is
a domain controller and the <a href="4339df3c-494b-49b4-9c60-d25526a35a0d#gt_c36db657-3138-4d9a-9289-ded5cbb8b40e" data-linktype="relative-path">directory
service</a> is enabled, set the <b>Flags</b> member of the DomainInfoBasic
structure as follows:</p>
<ol><li><p><span>   
</span>Set the DSROLE_PRIMARY_DS_RUNNING bit.</p>
</li><li><p><span>   
</span>If the domain is in mixed mode, set the DSROLE_PRIMARY_DS_MIXED_MODE bit.</p>
</li><li><p><span>   
</span>If the server is a read-only domain controller, set the
DSROLE_PRIMARY_DS_READONLY bit. The domain hosted by a <a href="4339df3c-494b-49b4-9c60-d25526a35a0d#gt_8b0a073b-3099-4efe-8b81-c2886b66a870" data-linktype="relative-path">read-only domain controller</a>
SHOULD<a id="Appendix_A_Target_14"></a><a aria-label="Product behavior note 14" href="9eaff666-129a-486e-ba94-1193d51f5a5b#Appendix_A_14" data-linktype="relative-path">&lt;14&gt;</a>  be in <a href="4339df3c-494b-49b4-9c60-d25526a35a0d#gt_8adcb510-b25d-459e-9832-90079803d3c0" data-linktype="relative-path">native mode</a>.</p>
</li></ol></li></ol><p><b>DsRoleUpgradeStatus</b></p><p>When InfoLevel is DsRoleUpgradeStatus, the server sets the
requested information into the <b>UpgradStatusInfo</b> field of the <i>DomainInfo</i>
parameter, whose type is DSROLE_UPGRADE_STATUS_INFO. The result MUST be
constructed in the following manner:</p><ol><li><p><span>    </span>Set the
OperationState field to DSROLE_UPGRADE_IN_PROGRESS if the ComputerUpgrade state
element is TRUE.</p>
</li><li><p><span>    </span>Set the
PreviousServerState field to the PreviousServerState state element.</p>
</li></ol><p><b>DsRoleOperationState</b></p><p>When InfoLevel is DsRoleOperationState, the server MUST
return the result in the <b>OperationStateInfo</b> field of the <i>DomainInfo</i>
parameter, whose type is DSROLE_OPERATION_STATE_INFO. The result MUST be
constructed by setting the <b>OperationState</b> member of the
OperationStateInfo structure according to the value of the
ComputerOperationState state element.</p></div>