<div class="content" name="NetrShareEnum" uuid="c4a98e7b-d416-439c-97bd-4d9f52f8ba52"><p>The NetrShareEnum method retrieves information about each
shared resource on a <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a>.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrShareEnum(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in, out] LPSHARE_ENUM_STRUCT InfoStruct,
   [in] DWORD PreferedMaximumLength,
   [out] DWORD* TotalEntries,
   [in, out, unique] DWORD* 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 <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a> 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). If this parameter is NULL, the local computer is used.</p><p><b>InfoStruct: </b>A pointer to a structure, in the
format of a <a href="79ee052e-e16b-4ec5-b4b7-e99777c26eca" data-linktype="relative-path">SHARE_ENUM_STRUCT (section 2.2.4.38)</a>,
as specified in section 2.2.4.38. The <b>SHARE_ENUM_STRUCT</b> structure has a <b>Level</b>
member that specifies the type of structure to return in the <b>ShareInfo</b>
member. The <b>Level</b> member MUST be one of the values specified in section
2.2.4.38.</p><p><b>PreferedMaximumLength: </b>Specifies the preferred
maximum length, in bytes, of the returned data. If the specified value is
MAX_PREFERRED_LENGTH, 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 share search in <b>ShareList</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 a nonzero value that can be passed in subsequent calls
to this method to continue with the enumeration in <b>ShareList</b>.</p><dl>
<dd>
<p>If this parameter is NULL or points to 0x00000000,
the enumeration starts from the beginning of the <b>ShareList</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>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><tr>
  <td>0x0000007C ERROR_INVALID_LEVEL</td>
  <td>The system call level is not correct.</td>
 </tr></tbody></table>
</dd></dl><p>If <i>ServerName</i> does not match any <b>Transport.ServerName</b>
in <b>TransportList</b> with the SVTI2_SCOPED_NAME bit set in <b>Transport.Flags</b>,
the server MUST reset <i>ServerName</i> as &#34;*&#34;.</p><p>The server MUST remove any preceding &#34;\\&#34; from the
<i>ServerName</i> parameter and normalize the <i>ServerName</i> parameter as
specified in section <a href="281119a2-9545-4d8d-b186-6e85b412f4ff" data-linktype="relative-path">3.1.6.8</a>,
passing in the updated <i>ServerName</i> parameter as the ServerName, and an
empty string as the ShareName.</p><p>In response to a NetrShareEnum request, the server MUST
enumerate the Share entries in <b>ShareList</b> based on the value of the <i>ResumeHandle</i>
parameter and query share properties by invoking the underlying server events
as specified in <a href="../ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b" data-linktype="relative-path">[MS-CIFS]</a>
section <a href="../ms-cifs/c5193839-4cd5-4f95-8ada-df13584251ce" data-linktype="relative-path">3.3.4.12</a>
or <a href="../ms-smb/f210069c-7086-4dc2-885e-861d837df688" data-linktype="relative-path">[MS-SMB]</a>
section <a href="../ms-smb/8708a390-e791-48d7-aa2a-bdaceaefecbd" data-linktype="relative-path">3.3.4.7</a>,
and <a href="../ms-smb2/5606ad47-5ee0-437a-817e-70c366052962" data-linktype="relative-path">[MS-SMB2]</a>
section <a href="../ms-smb2/13acd5bf-3518-4dfd-8e06-a2e5cc45bf04" data-linktype="relative-path">3.3.4.16</a>,
providing the tuple <i>&lt;normalized server name, Share.ShareName&gt;</i> as
the input parameter. When the server receives STATUS_SUCCESS for a share, it
MUST consider the received <a href="0448e06c-91b2-4ca6-bd9c-02ed396a3fbc" data-linktype="relative-path">SHARE_INFO_503_I</a>
and <a href="8a481783-9c6e-4f17-99d1-aea6578e21fb" data-linktype="relative-path">SHARE_INFO_1005</a>
structures as valid. The server MUST return information about each shared
resource on a server.</p><p>The <i>InfoStruct</i> parameter has a <b>Level</b> member.
The valid values of <b>Level</b> are 0, 1, 2, 501, 502, and 503. If the <b>Level</b>
member is not equal to one of the valid values, the server MUST fail the call
with an ERROR_INVALID_LEVEL error code.</p><p>The server MUST use the shares in valid SHARE_INFO_503_I and
SHARE_INFO_1005 structures returned from either CIFS or SMB2 server and fill
the return structures as follows. For each <b>share</b>, the server MUST
discard the structures received from other file server except the value of <b>share.shi503_current_uses</b>.</p><p>If the <b>Level</b> member is 503, the server MUST return
all shares in SHARE_INFO_503_I structures. Otherwise, the server MUST return
the <b>shares</b> in which share.shi503_servername matches <i>ServerName</i>.</p><p>If the <b>Level</b> member is 0, the server MUST return the
information about <b>share</b> resources by filling the <a href="d1c53c5e-dc80-4f0d-a85e-56f58829219b" data-linktype="relative-path">SHARE_INFO_0_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_0_CONTAINER structure contains an array of <a href="73a25288-8086-4975-91a3-5cbee5b590cc" data-linktype="relative-path">SHARE_INFO_0</a> structures.</p><ul><li><p><span><span> 
</span></span><b>shi0_netname</b> MUST be set to <b>share.shi503_netname</b>.</p>
</li></ul><p>If the <b>Level</b> member is 1, the server MUST return the
information about <b>share</b> resources by filling the <a href="919abd5d-87d9-4ffa-b4b1-632a66053bc6" data-linktype="relative-path">SHARE_INFO_1_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_1_CONTAINER structure contains an array of <a href="fc69f110-998d-4c16-9667-514e22fdd80b" data-linktype="relative-path">SHARE_INFO_1</a> structures.</p><ul><li><p><span><span> 
</span></span><b>shi1_netname</b> MUST be set to <b>share.shi503_netname</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi1_type</b> MUST be set to <b>share.shi503_type</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi1_remark</b> MUST be set to <b>share.shi503_remark</b>.</p>
</li></ul><p>If the <b>Level</b> member is 2, the server MUST return the
information about <b>share</b> resources by filling the <a href="f4dbaa4a-2048-4192-80cd-ea85ae920e5f" data-linktype="relative-path">SHARE_INFO_2_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_2_CONTAINER structure contains an array of <a href="baead467-920e-4278-853b-bbd303aadfd6" data-linktype="relative-path">SHARE_INFO_2</a> structures.</p><ul><li><p><span><span> 
</span></span><b>shi2_netname</b> MUST be set to <b>share.shi503_netname</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_type</b> MUST be set to <b>share.shi503_type</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_remark</b> MUST be set to <b>share.shi503_remark</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_permissions</b> MUST be set to <b>share.shi503_permissions</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_max_uses</b> MUST be set to <b>share.shi503_max_uses</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_current_uses</b> MUST be set to the sum of <b>share.shi503_current_uses</b>
values retrieved from both CIFS and SMB2 servers.</p>
</li><li><p><span><span> 
</span></span><b>shi2_path</b> MUST be set to <b>share.shi503_path</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi2_passwd</b> MUST be set to <b>share.shi503_passwd</b>.</p>
</li></ul><p>If the <b>Level</b> member is 501, the server MUST return
the information about <b>share</b> resources by filling the <a href="18fa9da8-8a98-4cbe-a026-899a4fb5eefe" data-linktype="relative-path">SHARE_INFO_501_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_501_CONTAINER structure contains an array of <a href="bd6fb43c-a7fc-4430-8567-bf558552dea3" data-linktype="relative-path">SHARE_INFO_501</a> structures.</p><ul><li><p><span><span> 
</span></span><b>shi501_netname</b> MUST be set to <b>share.shi503_netname</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi501_type</b> MUST be set to <b>share.shi503_type</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi501_remark</b> MUST be set to <b>share.shi503_remark</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi501_flags</b> MUST be set to <b>share.ShareFlags</b>.</p>
</li></ul><p>If the <b>Level</b> member is 502, the server MUST return
the information about <b>Share</b> resources by filling the <a href="1d5b0d11-6bb0-4b7f-8c14-c52873d469e7" data-linktype="relative-path">SHARE_INFO_502_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_502_CONTAINER structure contains an array of <a href="8605fd54-6ede-4316-b30d-ecfafa133c1d" data-linktype="relative-path">SHARE_INFO_502_I</a>
structures.</p><ul><li><p><span><span> 
</span></span><b>shi502_netname</b> MUST be set to <b>share.shi503_netname</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_type</b> MUST be set to <b>share.shi503_type</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_remark</b> MUST be set to <b>share.shi503_remark</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_permissions</b> MUST be set to <b>share.shi503_permissions</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_max_uses</b> MUST be set to <b>share.shi503_max_uses</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_current_uses</b> MUST be set to the sum of <b>share.shi503_current_uses</b>
values retrieved from both CIFS and SMB2 servers.</p>
</li><li><p><span><span> 
</span></span><b>shi502_path</b> MUST be set to <b>share.shi503_path</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_passwd</b> MUST be set to <b>share.shi503_passwd</b>.</p>
</li><li><p><span><span> 
</span></span><b>shi502_security_descriptor</b> MUST be set to <b>share.shi503_security_descriptor</b>.</p>
</li></ul><p>If the <b>Level</b> member is 503, the server MUST return
the information about <b>share</b> resources in the SHARE_INFO_503_I structure
by filling the <a href="a5a4f5d8-97df-43a0-a902-7ba4a843aca7" data-linktype="relative-path">SHARE_INFO_503_CONTAINER</a>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter,
except that <b>shi503_current_uses</b> MUST be set to the sum of <b>share.shi503_current_uses</b>
values retrieved from both CIFS and SMB2 server. The SHARE_INFO_503_CONTAINER
structure contains an array of SHARE_INFO_503_I structures.</p><p>The server MUST set the STYPE_CLUSTER_FS,
STYPE_CLUSTER_SOFS, and STYPE_CLUSTER_DFS bits in the shi*_type field to zero;
the client MUST ignore them on receipt.</p><p>The <i>PreferedMaximumLength</i> parameter specifies the
maximum number of bytes that the server can return for the <b>ShareInfo</b>
buffer. If <i>PreferedMaximumLength</i> is insufficient to hold all the
entries, the server MUST return the maximum number of entries that will fit in
the <b>ShareInfo</b> buffer and return ERROR_MORE_DATA. If this parameter is
equal to <a href="789ec187-e01b-4da6-a7ff-9cb9e0857230" data-linktype="relative-path">MAX_PREFERRED_LENGTH (section 2.2.2.2)</a>,
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 the share list in the order in
which shares are inserted into <b>ShareList</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 <b>ShareList</b>.</p>
</li><li><p><span><span> 
</span></span>If the <i>ResumeHandle</i> parameter points to a nonzero value,
the server MUST validate the <i>ResumeHandle</i>.</p>
<ul><li><p><span><span>  </span></span>If
the value of the <i>ResumeHandle</i> is less than the size of the <b>ShareList</b>,
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>ShareList</b>
after which enumeration is to begin.</p>
</li><li><p><span><span>  </span></span>If
the value of the <i>ResumeHandle</i> is greater than or equal to the size of
the <b>ShareList</b>, the server MUST return NERR_Success and zero entries.</p>
</li></ul></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 share in the <b>ShareList</b>.</p>
</li></ul><p>Because the <i>ResumeHandle</i> specifies the index into the
<b>ShareList</b>, and the <b>ShareList</b> 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 unavailable shares.</p><p>The server SHOULD<a id="Appendix_A_Target_58"></a><a aria-label="Product behavior note 58" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_58" data-linktype="relative-path">&lt;58&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_59"></a><a aria-label="Product behavior note 59" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_59" data-linktype="relative-path">&lt;59&gt;</a> fail the call.</p></div>