<div class="content"><p> </p><p>The <b>NetrUseEnum</b> method lists open connections between
a workstation server and a remote SMB server. The server SHOULD NOT allow this
method to be invoked remotely<a id="Appendix_A_Target_51"></a><a aria-label="Product behavior note 51" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_51" data-linktype="relative-path">&lt;51&gt;</a> and
SHOULD return ERROR_CALL_NOT_IMPLEMENTED.</p><dl>
<dd>
<div><pre> unsigned long NetrUseEnum(
   [in, string, unique] WKSSVC_IDENTIFY_HANDLE ServerName,
   [in, out] LPUSE_ENUM_STRUCT InfoStruct,
   [in] unsigned long PreferredMaximumLength,
   [out] unsigned long* TotalEntries,
   [in, out, unique] unsigned long* ResumeHandle
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>A <b>WKSSVC_IDENTIFY_HANDLE</b>
structure (section <span><a href="9ef94a11-0e5c-49d7-9ac7-68d6f03565de" data-linktype="relative-path">2.2.2.1</a></span>) that
identifies the <span><a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server (2)</a></span>. The <span><a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a></span>
MUST map this structure to an <span><a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a></span> binding handle (<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). The server MUST ignore this parameter.</p><p><b>InfoStruct: </b>The <b>USE_ENUM_STRUCT</b>
structure (section <span><a href="7ecd0a94-9d61-4d0b-8151-7729c9d03620" data-linktype="relative-path">2.2.5.29</a></span>) contains
a <i>Level</i> parameter that indicates the type of structure to return.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  </td>
  <td>
  <p>Specifies a local device name and the share name of a
  remote resource.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000001</p>
  </td>
  <td>
  <p>Specifies details about the connection between a local
  device and a shared resource, including connection status and connection
  type.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000002</p>
  </td>
  <td>
  <p>Specifies details about the connection between a local
  device and a shared resource, including connection status, connection type,
  user name, and domain name.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p><b>PreferredMaximumLength: </b>The number of bytes to
allocate for the return data.</p><p><b>TotalEntries: </b>The total number of entries that
could have been enumerated if the buffer were big enough to hold all the
entries.</p><p><b>ResumeHandle: </b>A pointer that, if specified and
if this method returns ERROR_MORE_DATA, MUST receive an implementation-specific
value that can be passed in subsequent calls to this method in order to
continue with the enumeration of currently logged-on users.</p><dl>
<dd>
<p>If this parameter is NULL or points to zero, the
enumeration MUST start from the beginning of the list of currently logged-on
users.</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 (<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>Value/code</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>NERR_Success</p>
  <p>0x00000000</p>
  </td>
  <td>
  <p>The client request succeeded.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_INVALID_LEVEL</p>
  <p>0x0000007C</p>
  </td>
  <td>
  <p>The system call level is not correct.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_MORE_DATA</p>
  <p>0x000000EA</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>PreferredMaximumLength</i>.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_NOT_ENOUGH_MEMORY</p>
  <p>0x00000008</p>
  </td>
  <td>
  <p>Not enough storage is available to process this
  command.</p>
  </td>
 </tr><tr>
  <td>
  <p>NERR_BufTooSmall</p>
  <p>0x0000084B</p>
  </td>
  <td>
  <p>The client request succeeded. More entries are
  available. The buffer size that is specified by <i>PreferredMaximumLength</i>
  was too small to fit even a single entry.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The server SHOULD<a id="Appendix_A_Target_52"></a><a aria-label="Product behavior note 52" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_52" data-linktype="relative-path">&lt;52&gt;</a> enforce
security measures to verify that the caller has the required permissions to
execute this routine. If the server enforces security measures and the caller
does not have the required credentials, the server MUST fail the call with
ERROR_ACCESS_DENIED. Specifications for determining the identity of the caller
for the purpose of performing an access check are in <span><a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a></span>
section <span><a href="../ms-rpce/0e5b0e1c-0ba5-4342-bc36-30c66a9d07fd" data-linktype="relative-path">3.3.3.1.3</a></span>.</p><p>The <i>InfoStruct</i> parameter has a <b>Level</b> member.
The value of <b>Level</b> MUST be 0, 1, or 2. If the Level 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 invoke the event to impersonate the client
([MS-RPCE] section <span><a href="../ms-rpce/a996aa17-8e04-4a25-806a-a3c724230e12" data-linktype="relative-path">3.3.3.4.3.1</a></span>),
passing in NULL as input parameter. If this event fails, the server MUST return
an error. If the event returns UserToken, the server MUST look in the <b>UseTable</b>
for the user where <b>UseEntry.UserToken</b> matches UserToken. If no match is
found, the server MUST set the value of <i>TotalEntries</i> to 0 and return a
NERR_Success.</p><p>If a matching UserToken is found for the user in <b>UseTable</b>,
the server MUST enumerate connections in <b>UseEntry.ConnectionTable</b> and
fill the return structures as follows:</p><ul><li><p><span><span> 
</span></span>If the <b>Level</b> member is 0, the server MUST return details
about the connection by filling the <b>USE_INFO_0_CONTAINER</b> structure
(section <span><a href="93aed681-2e57-41f7-84ca-4fb14ad5b7ba" data-linktype="relative-path">2.2.5.26</a></span>) in the <b>Buffer</b>
field of the <i>InfoStruct</i> parameter as follows. <b>USE_INFO_0_CONTAINER</b>
contains an array of <b>USE_INFO_0</b> structures (section <span><a href="c6253242-d630-40ba-bded-f69695357ef3" data-linktype="relative-path">2.2.5.22</a></span>).</p>
<ul><li><p><span><span>  </span></span><b>ui0_local</b>
set to <b>Connection.local</b></p>
</li><li><p><span><span>  </span></span><b>ui0_remote</b>
set to <b>Connection.remote</b></p>
</li></ul></li><li><p><span><span> 
</span></span>If the <b>Level</b> member is 1, the server MUST return details
about the connection by filling the <b>USE_INFO_1_CONTAINER</b> structure
(section <span><a href="21a7e830-91b0-416e-a151-7760f3646d68" data-linktype="relative-path">2.2.5.27</a></span>) in the <b>Buffer</b>
field of the <i>InfoStruct</i> parameter as follows. The <b>USE_INFO_1_CONTAINER</b>
structure contains an array of <b>USE_INFO_1</b> structures (section <span><a href="969d330b-fffa-4c4f-8331-62b3989086ff" data-linktype="relative-path">2.2.5.23</a></span>).</p>
<ul><li><p><span><span>  </span></span><b>ui1_local</b>
set to <b>Connection.local</b></p>
</li><li><p><span><span>  </span></span><b>ui1_remote</b>
set to <b>Connection.remote</b></p>
</li><li><p><span><span>  </span></span><b>ui1_password</b>
set to NULL</p>
</li><li><p><span><span>  </span></span><b>ui1_status</b>
set to <b>Connection.status</b></p>
</li><li><p><span><span>  </span></span><b>ui1_asg_type</b>
set to <b>Connection.asgtype</b></p>
</li><li><p><span><span>  </span></span><b>ui1_refcount</b>
set to <b>Connection.refcount</b></p>
</li><li><p><span><span>  </span></span><b>ui1_usecount</b>
set to <b>Connection.useCount</b></p>
</li></ul></li><li><p><span><span> 
</span></span>If the <b>Level</b> member is 2, the server MUST return details
about the connection by filling the <b>USE_INFO_2_CONTAINER</b> structure
(section <span><a href="f739de8a-b363-488e-a9c8-190ac6234189" data-linktype="relative-path">2.2.5.28</a></span>) in the <b>Buffer</b>
field of the <i>InfoStruct</i> parameter as follows. <b>USE_INFO_2_CONTAINER</b>
contains an array of <b>USE_INFO_2</b> structures (section <span><a href="144e75a6-cda2-4418-96b9-e6867b50bfba" data-linktype="relative-path">2.2.5.24</a></span>).</p>
<ul><li><p><span><span>  </span></span><b>ui2_local</b>
set to <b>Connection.local</b></p>
</li><li><p><span><span>  </span></span><b>ui2_remote</b>
set to <b>Connection.remote</b></p>
</li><li><p><span><span>  </span></span><b>ui2_password</b>
set to NULL</p>
</li><li><p><span><span>  </span></span><b>ui2_status</b>
set to <b>Connection.status</b></p>
</li><li><p><span><span>  </span></span><b>ui2_asg_type</b>
set to <b>Connection.asgtype</b></p>
</li><li><p><span><span>  </span></span><b>ui2_refcount</b>
set to <b>Connection.refcount</b></p>
</li><li><p><span><span>  </span></span><b>ui2_usecount</b>
set to <b>Connection.useCount</b></p>
</li><li><p><span><span>  </span></span><b>ui2_domainname</b>
set to <b>Connection.domain</b></p>
</li></ul></li></ul><p>If the <i>PreferredMaximumLength</i> parameter equals <b>MAX_PREFERRED_LENGTH</b>
(section <span><a href="68338fae-259c-4a06-8793-9be93cf492ff" data-linktype="relative-path">2.2.1.3</a></span>), the
server MUST return all the requested data. If <i>PreferredMaximumLength</i> is
insufficient to hold all the entries, the server MUST return the maximum number
of entries that fit in the <i>InfoStruct</i> buffer and return
NERR_BufTooSmall.</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 either is NULL or points to
0x00000000, the enumeration MUST start from the beginning of the list of the
currently established connections.</p>
</li><li><p><span><span> 
</span></span>If the <i>ResumeHandle</i> parameter is nonzero, the server MUST
begin enumeration based on the value of <i>ResumeHandle</i>. The server is not
required to maintain any state between calls invoking the <b>NetrUseEnum</b>
method.</p>
</li><li><p><span><span> 
</span></span>If the client specified <i>ResumeHandle</i> and if the server
returns NERR_BufTooSmall, the server MUST set <i>ResumeHandle</i> to an
implementation-specific value<a id="Appendix_A_Target_53"></a><a aria-label="Product behavior note 53" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_53" data-linktype="relative-path">&lt;53&gt;</a> that
allow the server to continue with this enumeration on a subsequent call to this
method, using the same value for <i>ResumeHandle</i>.</p>
</li></ul><p>The server is not required to maintain any state between
calls to the <b>NetrUseEnum</b> method. If the server returns NERR_Success, 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. If the server
returns NERR_BufTooSmall, it SHOULD set the <i>TotalEntries</i> value to the
total number of entries that could have been enumerated from the current resume
position.</p><p>The server MUST invoke the event to end the client
impersonation ([MS-RPCE] section <span><a href="../ms-rpce/53d8f057-4e3a-4bc4-9355-a1cd781de901" data-linktype="relative-path">3.3.3.4.3.3</a></span>).</p></div>