<div class="content" name="NetrGetAnyDCName" uuid="3db726ac-0d1b-43be-bd6f-923d97768436"><p>The <b>NetrGetAnyDCName</b> method MAY<a id="Appendix_A_Target_165"></a><a aria-label="Product behavior note 165" href="0c858a52-732a-43ec-85dd-e44b357c1898#Appendix_A_165" data-linktype="relative-path">&lt;165&gt;</a> be used to retrieve the name
of a <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_76a05049-3531-4abd-aec8-30e19954b4bd" data-linktype="relative-path">domain
controller</a></span> in the specified primary or directly <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_5ee032d0-d944-4acb-bbb5-b1cfc7df6db6" data-linktype="relative-path">trusted</a></span>
domain. Only DCs can return the name of a DC in a specified directly trusted
domain. </p><dl>
<dd>
<div><pre> NET_API_STATUS NetrGetAnyDCName(
   [in, unique, string] LOGONSRV_HANDLE ServerName,
   [in, unique, string, range(0,256)] wchar_t* DomainName,
   [out, string] wchar_t** Buffer
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>The custom <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_44deb72d-c62b-4335-90e4-b9fd4dd782ed" data-linktype="relative-path">binding
handle</a></span>, as defined in section <span><a href="3b224201-b531-43e2-8c79-b61f6dea8640" data-linktype="relative-path">3.5.4.1</a></span>.</p><p><b>DomainName: </b>A null-terminated <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_c305d0ab-8b94-461a-bd76-13b40cb8c4d8" data-linktype="relative-path">Unicode</a></span>
string that contains the name of the primary or directly trusted domain. If the
string is NULL or empty (that is, the first character in the string is the
null-terminator character), the primary <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_45a1c9f1-0263-49a8-97c7-7aca1a99308c" data-linktype="relative-path">domain name</a></span> is assumed.</p><p><b>Buffer: </b>A pointer to an allocated buffer that
contains the null-terminated Unicode string containing the <span><a href="b5e7d25a-40b2-41c8-9611-98f53358af66#gt_0334e0bd-2755-42f6-aeff-2d4a22bf4abf" data-linktype="relative-path">NetBIOS
name</a></span> of a DC in the specified domain. The DC name is prefixed by two
backslashes (\\).</p><p><b>Return Values: </b>The method returns 0x00000000
on success; otherwise, it MUST return a nonzero error code and SHOULD return
the following error code.</p><table><thead>
  <tr>
   <th>
   <p>Return Value/Code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000712 ERROR_DOMAIN_TRUST_INCONSISTENT</td>
  <td>The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.</td>
 </tr></tbody></table><p>Verify that the client has
sufficient privileges. The server determines if the client has sufficient
privileges (as specified in section <span><a href="1ec94886-2b64-45af-b68e-3d9faa36617c" data-linktype="relative-path">3.5.4.2</a></span>). If the
server is not a domain controller the Access Request mask is set to
NETLOGON_WKSTA_RPC_ACCESS. If the server is a domain controller the Access
Request mask is set to NETLOGON_DCLOC_RPC_ACCESS.<a id="Appendix_A_Target_166"></a><a aria-label="Product behavior note 166" href="0c858a52-732a-43ec-85dd-e44b357c1898#Appendix_A_166" data-linktype="relative-path">&lt;166&gt;</a> If the
client does not have sufficient privileges the server MUST return
ERROR_ACCESS_DENIED.</p><p>The server MUST attempt to locate a DC for the domain
specified by the client. The server SHOULD<a id="Appendix_A_Target_167"></a><a aria-label="Product behavior note 167" href="0c858a52-732a-43ec-85dd-e44b357c1898#Appendix_A_167" data-linktype="relative-path">&lt;167&gt;</a>
implement alternate means to locate domain controllers: for example, a static
list in a file, or the two methods detailed in <span><a href="../ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a" data-linktype="relative-path">[MS-ADTS]</a></span>
section <span><a href="../ms-adts/3e9711af-9067-435e-93fb-09182053cef7" data-linktype="relative-path">6.3.6</a></span>.
If the server that receives this call is the PDC for the domain specified in
DomainName, the server MUST return ERROR_NO_SUCH_DOMAIN.</p><p>If the <i>ServerName</i> parameter is not a valid binding
handle (as defined in section 3.5.4.1), the server MUST return
ERROR_INVALID_COMPUTERNAME.</p><p>This method also returns errors based on Common Error
Processing Rule E, specified in section <span><a href="2d776bfc-e81f-4c8f-9da8-4c2920f65413" data-linktype="relative-path">3</a></span>.</p><p>NetrGetAnyDcName returns the name of the discovered DC.</p></div>