<div class="content" name="NetrServerAliasEnum" uuid="b8f42b05-7feb-43c9-8409-ce13260ce127"><p>The NetrServerAliasEnum method retrieves alias information
for a <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a> based on
specified alias name or server name.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrServerAliasEnum(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in, out] LPSERVER_ALIAS_ENUM_STRUCT InfoStruct,
   [in] DWORD PreferedMaximumLength,
   [out] LPDWORD TotalEntries,
   [in, out, unique] LPDWORD ResumeHandle
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>An <a href="5f8329ee-1965-4ea1-ad35-3b29fbb63232" data-linktype="relative-path">SRVSVC_HANDLE (section 2.2.1.1)</a>
pointer that identifies the server. The client MUST map this structure to an
RPC binding handle (see <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>InfoStruct: </b>A pointer to a structure, in the
format of a <a href="9c634bfb-e899-44ba-9ebe-d3580484e9d9" data-linktype="relative-path">SERVER_ALIAS_ENUM_STRUCT</a>,
as specified in section 2.2.4.104. The SERVER_ALIAS_ENUM_STRUCT structure has a
<b>Level</b> member that specifies the type of structure to return in the <b>ServerAliasInfo</b>
member. The <b>Level</b> member MUST be one of the values specified in section
2.2.4.104.</p><p><b>PreferedMaximumLength: </b>Specifies the preferred
maximum length, in bytes, of the returned data. If the specified value is <a href="789ec187-e01b-4da6-a7ff-9cb9e0857230" data-linktype="relative-path">MAX_PREFERRED_LENGTH</a>, the
method MUST attempt to return all entries.</p><p><b>TotalEntries: </b>The total number of entries that
could have been enumerated if the buffer had been big enough to hold all the entries.</p><p><b>ResumeHandle: </b>A pointer to a value that
contains a handle, which is used to continue an existing alias search in <b>AliasList</b>.
The handle MUST be zero on the first call and remain unchanged for subsequent
calls. If the <i>ResumeHandle</i> parameter is NULL, no resume handle MUST be
stored. If this parameter is not NULL and the method returns ERROR_MORE_DATA,
this parameter receives an implementation-specific nonzero value that can be
passed in subsequent calls to this method to continue with the enumeration.</p><dl>
<dd>
<p>If this parameter is NULL or points to 0x00000000,
the enumeration starts from the beginning of the <b>AliasList</b>.</p>
</dd></dl><p><b>Return Values: </b>The method returns 0x00000000
(NERR_Success) to indicate success; otherwise, it returns a nonzero error code.
The method can take any specific error code value, as specified in <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>.
The most common error codes are listed in the following table.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 NERR_Success</td>
  <td>The client request succeeded.</td>
 </tr><tr>
  <td>0x00000005 ERROR_ACCESS_DENIED</td>
  <td>Access is denied.</td>
 </tr><tr>
  <td>0x00000057 ERROR_INVALID_PARAMETER</td>
  <td>The client request failed because the specified parameter is invalid.</td>
 </tr><tr>
  <td>0x00000008 ERROR_NOT_ENOUGH_MEMORY</td>
  <td>Not enough storage is available to process this command.</td>
 </tr><tr>
  <td>0x0000084B NERR_BufTooSmall</td>
  <td>The allocated buffer is too small to hold single entry.</td>
 </tr><tr>
  <td>0x0000007C ERROR_INVALID_LEVEL</td>
  <td>The system call level is not correct.</td>
 </tr><tr>
  <td>0x000000EA ERROR_MORE_DATA</td>
  <td>The client request succeeded. More entries are available. Not all entries could be returned in the buffer size that is specified by PreferedMaximumLength.</td>
 </tr></tbody></table>
</dd></dl><p>In response to a NetrServerAliasEnum message, the server
MUST return information about each alias resource on a server, or return an
error code.</p><p>The <i>InfoStruct</i> parameter has a Level member. The
valid values of <b>Level</b> are 0. If the <b>Level</b> member is not equal to
0, the server MUST fail the call with an ERROR_INVALID_LEVEL error code.</p><p>If the <b>Level</b> member is 0, the server MUST return the
information about aliases by filling the <a href="79580d1c-fa06-4884-9b93-8d08d9d706cd" data-linktype="relative-path">SERVER_ALIAS_INFO_0_CONTAINER</a>
structure in the <b>ServerAliasInfo</b> member of the <i>InfoStruct</i>
parameter. The SERVER_ALIAS_INFO_0_CONTAINER structure contains an array of <a href="02a5b8d8-9725-475d-981c-d058c446bb8d" data-linktype="relative-path">SERVER_ALIAS_INFO_0</a>
structures.</p><p>The <i>PreferedMaximumLength</i> parameter specifies the
maximum number of bytes that the server can return for the <b>ServerAliasInfo</b>
buffer. If <i>PreferedMaximumLength</i> is insufficient to hold all the
entries, the server MUST return the maximum number of entries as will fit in
the <b>ServerAliasInfo</b> buffer and return ERROR_MORE_DATA. If this parameter
is equal to MAX_PREFERRED_LENGTH, the server MUST return all the requested
data.</p><p>If the server returns NERR_Success or ERROR_MORE_DATA, it
MUST set the <i>TotalEntries</i> parameter to equal the total number of entries
that could have been enumerated from the current resume position.</p><p>If <i>PreferedMaximumLength</i> is insufficient to hold all
the entries and if the client has specified a <i>ResumeHandle</i>, the server
MUST set <i>ResumeHandle</i> to some implementation-specific value that allows
the server to continue with this enumeration on a subsequent call to this
method with the same value for <i>ResumeHandle</i>.</p><p>The server MUST maintain <b>AliasList</b>.</p><p>The following rules specify processing of the <i>ResumeHandle</i>
parameter:</p><ul><li><p><span><span> 
</span></span>If the <i>ResumeHandle</i> parameter is either NULL or points to
0x00000000, the enumeration MUST start from the beginning of the list of the <b>AliasList</b>.</p>
</li><li><p><span><span> 
</span></span>If the <i>ResumeHandle</i> parameter points to a nonzero value,
the server MUST continue enumeration based on the value of <i>ResumeHandle</i>.
The value of <i>ResumeHandle</i> specifies the index into the <b>AliasList</b>
after which the enumeration is to begin.</p>
</li><li><p><span><span> 
</span></span>If the client specified a <i>ResumeHandle</i> and if the server
returns ERROR_MORE_DATA (0x000000EA), the server MUST set <i>ResumeHandle</i>
to the index of the last enumerated alias in the <b>AliasList</b>.</p>
</li></ul><p>Because the <i>ResumeHandle</i> specifies an offset into the
list, and the list of aliases can be modified between multiple requests, the
results of a query spanning multiple requests using the <i>ResumeHandle</i> can
be unreliable, offering either duplicate or missed aliases.</p><p>The server SHOULD<a id="Appendix_A_Target_173"></a><a aria-label="Product behavior note 173" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_173" data-linktype="relative-path">&lt;173&gt;</a>
enforce security measures to verify that the caller has the required
permissions to execute this routine. If the caller does not have the required
credentials, the server SHOULD<a id="Appendix_A_Target_174"></a><a aria-label="Product behavior note 174" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_174" data-linktype="relative-path">&lt;174&gt;</a> fail
the call.</p></div>