<div class="content"><p> </p><p>The NetrShareEnum method retrieves information about each
shared resource on a <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a></span>.</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 <span><a href="5f8329ee-1965-4ea1-ad35-3b29fbb63232" data-linktype="relative-path">SRVSVC_HANDLE (section 2.2.1.1)</a></span>
pointer that identifies the server. The <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a></span> MUST map this
structure to an RPC binding handle (see <span><a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a></span> 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 <span><a href="79ee052e-e16b-4ec5-b4b7-e99777c26eca" data-linktype="relative-path">SHARE_ENUM_STRUCT (section 2.2.4.38)</a></span>,
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 <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>
section <span><a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a></span>.
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>
  <p>0x00000000</p>
  <p>NERR_Success</p>
  </td>
  <td>
  <p>The client request succeeded.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x000000EA</p>
  <p>ERROR_MORE_DATA</p>
  </td>
  <td>
  <p>The client request succeeded. More entries are
  available. Not all entries could be returned in the buffer size that is
  specified by <i>PreferedMaximumLength</i>.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x0000007C</p>
  <p>ERROR_INVALID_LEVEL</p>
  </td>
  <td>
  <p>The system call level is not correct.</p>
  </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 <span><a href="281119a2-9545-4d8d-b186-6e85b412f4ff" data-linktype="relative-path">3.1.6.8</a></span>, 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 <span><a href="../ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b" data-linktype="relative-path">[MS-CIFS]</a></span>
section <span><a href="../ms-cifs/c5193839-4cd5-4f95-8ada-df13584251ce" data-linktype="relative-path">3.3.4.12</a></span>
or <span><a href="../ms-smb/f210069c-7086-4dc2-885e-861d837df688" data-linktype="relative-path">[MS-SMB]</a></span>
section <span><a href="../ms-smb/8708a390-e791-48d7-aa2a-bdaceaefecbd" data-linktype="relative-path">3.3.4.7</a></span>,
and <span><a href="../ms-smb2/5606ad47-5ee0-437a-817e-70c366052962" data-linktype="relative-path">[MS-SMB2]</a></span>
section <span><a href="../ms-smb2/13acd5bf-3518-4dfd-8e06-a2e5cc45bf04" data-linktype="relative-path">3.3.4.16</a></span>,
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 <span><a href="0448e06c-91b2-4ca6-bd9c-02ed396a3fbc" data-linktype="relative-path">SHARE_INFO_503_I</a></span>
and <span><a href="8a481783-9c6e-4f17-99d1-aea6578e21fb" data-linktype="relative-path">SHARE_INFO_1005</a></span>
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 <span><a href="d1c53c5e-dc80-4f0d-a85e-56f58829219b" data-linktype="relative-path">SHARE_INFO_0_CONTAINER</a></span>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_0_CONTAINER structure contains an array of <span><a href="73a25288-8086-4975-91a3-5cbee5b590cc" data-linktype="relative-path">SHARE_INFO_0</a></span>
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 <span><a href="919abd5d-87d9-4ffa-b4b1-632a66053bc6" data-linktype="relative-path">SHARE_INFO_1_CONTAINER</a></span>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_1_CONTAINER structure contains an array of <span><a href="fc69f110-998d-4c16-9667-514e22fdd80b" data-linktype="relative-path">SHARE_INFO_1</a></span>
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 <span><a href="f4dbaa4a-2048-4192-80cd-ea85ae920e5f" data-linktype="relative-path">SHARE_INFO_2_CONTAINER</a></span>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_2_CONTAINER structure contains an array of <span><a href="baead467-920e-4278-853b-bbd303aadfd6" data-linktype="relative-path">SHARE_INFO_2</a></span>
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 <span><a href="18fa9da8-8a98-4cbe-a026-899a4fb5eefe" data-linktype="relative-path">SHARE_INFO_501_CONTAINER</a></span>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_501_CONTAINER structure contains an array of <span><a href="bd6fb43c-a7fc-4430-8567-bf558552dea3" data-linktype="relative-path">SHARE_INFO_501</a></span>
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 <span><a href="1d5b0d11-6bb0-4b7f-8c14-c52873d469e7" data-linktype="relative-path">SHARE_INFO_502_CONTAINER</a></span>
structure in the <b>ShareInfo</b> member of the <i>InfoStruct</i> parameter.
The SHARE_INFO_502_CONTAINER structure contains an array of <span><a href="8605fd54-6ede-4316-b30d-ecfafa133c1d" data-linktype="relative-path">SHARE_INFO_502_I</a></span>
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 <span><a href="a5a4f5d8-97df-43a0-a902-7ba4a843aca7" data-linktype="relative-path">SHARE_INFO_503_CONTAINER</a></span>
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 <span><a href="789ec187-e01b-4da6-a7ff-9cb9e0857230" data-linktype="relative-path">MAX_PREFERRED_LENGTH (section 2.2.2.2)</a></span>,
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_57"></a><a aria-label="Product behavior note 57" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_57" data-linktype="relative-path">&lt;57&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_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> fail the call.</p></div>