<div class="content" name="NetrEnumerateComputerNames" uuid="4a317cb7-4cc0-427a-a95d-cdef445f6241"><p>The <b>NetrEnumerateComputerNames</b> method returns a list
of <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_9a7bc8b3-3374-4608-8f73-be20a90b898b" data-linktype="relative-path">computer names</a> for a
specified <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server (2)</a>.
The results of the query are determined by the type of the name. <a id="Appendix_A_Target_120"></a><a aria-label="Product behavior note 120" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_120" data-linktype="relative-path">&lt;120&gt;</a></p><dl>
<dd>
<div><pre> unsigned long NetrEnumerateComputerNames(
   [in, string, unique] WKSSVC_IMPERSONATE_HANDLE ServerName,
   [in] NET_COMPUTER_NAME_TYPE NameType,
   [in] unsigned long Reserved,
   [out] PNET_COMPUTER_NAME_ARRAY* ComputerNames
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>A <b>WKSSVC_IMPERSONATE_HANDLE</b>
structure (section <a href="2427e140-22b3-45f8-9e12-1b3593308e46" data-linktype="relative-path">2.2.2.2</a>)
that specifies the server. The <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a> MUST map this
structure to an <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a>
binding <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a> (<a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a> sections 4.3.5
and 5.1.5.2). The server MUST ignore this parameter.</p><p><b>NameType: </b>The type of query issued. See <b>NET_COMPUTER_NAME_TYPE
</b>(section <a href="10d46710-ae87-468a-a34e-52bef0170307" data-linktype="relative-path">2.2.3.3</a>).</p><p><b>Reserved: </b>A 32-bit bitfield that SHOULD be set
to zero.</p><dl>
<dd>
<table>
 <tbody><tr>
  <th><p><br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>1<br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>2<br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>3<br/>0</p></th>
  <th><p><br/>1</p></th>
 </tr>
 <tr>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>0</td>
  <td>IU</td>
 </tr>
</tbody></table>
</dd>
<dd>
<p>Where the bits are defined as:</p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>IU NET_IGNORE_UNSUPPORTED_FLAGS</td>
  <td>If 1, the server MUST ignore the values of the other bits in this field. If 0, the values of the other bits in this field MUST be 0; otherwise, the server MUST return ERROR_INVALID_FLAGS. &lt;121&gt;</td>
 </tr></tbody></table>
</dd></dl><p><b>ComputerNames: </b>A pointer to structure
containing a list of computer name strings. See <b>NET_COMPUTER_NAME_ARRAY</b>
(section <a href="2dc431fb-01c9-4cc9-bfc8-65cce9c6e649" data-linktype="relative-path">2.2.5.21</a>).</p><p><b>Return Values: </b>When the message processing
result meets the description in column two of the following table, this method
MUST return one of the following values (<a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a>).</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value/code</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>NERR_Success 0x00000000</td>
  <td>The operation completed successfully.</td>
 </tr><tr>
  <td>ERROR_ACCESS_DENIED 0x00000005</td>
  <td>Access is denied.</td>
 </tr><tr>
  <td>ERROR_NOT_ENOUGH_MEMORY 0x00000008</td>
  <td>Not enough storage is available to process this command.</td>
 </tr><tr>
  <td>ERROR_INVALID_PARAMETER 0x00000057</td>
  <td>The parameter is incorrect.</td>
 </tr><tr>
  <td>ERROR_NOT_SUPPORTED 0x00000032</td>
  <td>This method is not supported by this server.</td>
 </tr><tr>
  <td>ERROR_INVALID_FLAGS 0x000003EC</td>
  <td>Reserved contains an invalid value.</td>
 </tr><tr>
  <td>RPC_S_PROTSEQ_NOT_SUPPORTED 0x000006A7</td>
  <td>The RPC protocol sequence is not supported.</td>
 </tr><tr>
  <td>RPC_S_CALL_IN_PROGRESS 0x000006FF</td>
  <td>A remote procedure call is already in progress.</td>
 </tr></tbody></table>
</dd></dl><p>Any other return value MUST conform to the error code
requirements in <b>Protocol Details</b> (section <a href="aeea622a-ea3e-40cc-a9b1-b4a2a3b2bf6b" data-linktype="relative-path">3</a>).</p><p>The following statements define the sequence of message
processing operations.</p><ol><li><p><span>    </span>The server MUST
retrieve the RPC protocol sequence used for the current call (<a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>
section <a href="../ms-rpce/0ceefe4c-0d7a-423f-bcd0-54e821767f89" data-linktype="relative-path">3.1.3.4.1</a>),
specifying the server binding handle maintained by the RPC runtime ([C706]
section 6.2.1). If that RPC protocol sequence is not <b>NCACN_NP</b>, the
server SHOULD return <b>RPC_S_PROTSEQ_NOT_SUPPORTED</b>.<a id="Appendix_A_Target_122"></a><a aria-label="Product behavior note 122" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_122" data-linktype="relative-path">&lt;122&gt;</a></p>
</li><li><p><span>    </span>The server MUST
check that the caller has been granted access rights using the algorithm in the
<b>Access Control Abstract Data Model</b> (section <a href="c5b75090-3de2-404f-8de1-d5ca3fc38a70" data-linktype="relative-path">3.2.1.1</a>), with <i>Access
Request mask</i> initialized to <b>WKSTA_NETAPI_CHANGE_CONFIG</b>; if not, the
server MUST return ERROR_ACCESS_DENIED.</p>
</li><li><p><span>    </span>The server
SHOULD<a id="Appendix_A_Target_123"></a><a aria-label="Product behavior note 123" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_123" data-linktype="relative-path">&lt;123&gt;</a> return ERROR_NOT_SUPPORTED if
the server is a client <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_dcea8721-5213-4954-bc73-d75ad6cb5591" data-linktype="relative-path">SKU</a>
configuration.</p>
</li><li><p><span>    </span>The server MUST
return ERROR_INVALID_PARAMETER if <i>NameType</i> is greater than or equal to <b>NetComputerNameTypeMax</b>.</p>
</li><li><p><span>    </span>The server MUST
impersonate the client by invoking the <b>StartImpersonatingClient</b> task
(section <a href="719ae534-d5d7-4c42-9989-d63e0676fad1" data-linktype="relative-path">3.2.4.29.6</a>).
If this operation fails, the server MUST return an error.</p>
</li><li><p><span>    </span>The server MUST
initialize the output parameter <i>ComputerNames</i> as follows depending on
the input query type in <i>NameType</i>.</p>
<ul><li><p><span><span>  </span></span><b>NetPrimaryComputerName:</b></p>
<p>The server MUST set <i>ComputerNames.EntryCount</i>
to 1 and initialize the UNICODE_STRING values in <i>ComputerNames</i> to <b>ComputerNameFQDN</b>
(section <a href="e0b508bc-764d-48b7-b44b-4f93c3d5cf8c" data-linktype="relative-path">3.2.1.5</a>).</p>
</li><li><p><span><span>  </span></span><b>NetAlternateComputerNames:</b></p>
<p>The server MUST set <i>ComputerNames.EntryCount</i>
to the number of tuples contained in <b>alternate-computer-names</b> (section <a href="b1cb0684-fdeb-4fa2-8e12-c124ef64025f" data-linktype="relative-path">3.2.1.2</a>). For each tuple,
I, the server MUST initialize the next available UNICODE_STRING elements in the
<i>ComputerNames</i> array to equal the values stored in <i>alternate-computer-names[I]</i>.FQDN.</p>
</li><li><p><span><span>  </span></span><b>NetAllComputerNames:</b></p>
<p>The server MUST set <i>ComputerNames.EntryCount</i>
to the number of tuples contained in <b>alternate-computer-names</b> + 1. The <i>ComputerNames</i>
array MUST be initialized to return all the names specified for the <b>NetPrimaryComputerName</b>
and <b>NetAlternateComputerNames</b> input query types.</p>
</li></ul></li><li><p><span>    </span>The server MUST
stop impersonating the client by invoking the <b>StopImpersonatingClient</b>
task (section <a href="cf258b4a-d66b-4407-85f7-aac7823ec0aa" data-linktype="relative-path">3.2.4.29.7</a>).</p>
</li></ol><p>If no errors occur, the server MUST return NERR_Success.</p></div>