<div class="content"><p> </p><p>The <b>NetrWkstaUserEnum</b> method returns details about
users who are currently active on a remote computer.</p><dl>
<dd>
<div><pre> unsigned long NetrWkstaUserEnum(
   [in, string, unique] WKSSVC_IDENTIFY_HANDLE ServerName,
   [in, out] LPWKSTA_USER_ENUM_STRUCT UserInfo,
   [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 <span><a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a></span>
(<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>UserInfo: </b>A pointer to the buffer to receive
the data. The data MUST be returned as a <b>WKSTA_USER_ENUM_STRUCT</b>
structure (section <span><a href="4041455a-52be-4389-a4fc-82fea3cb3160" data-linktype="relative-path">2.2.5.14</a></span>) that
contains a <b>Level</b> member that specifies the type of structure to return.</p><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<a id="Appendix_A_Target_34"></a><a aria-label="Product behavior note 34" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_34" data-linktype="relative-path">&lt;34&gt;</a> that can
be passed in subsequent calls to this method, 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>When the message processing
result matches the description in column two of the following table, this
method MUST return one of the following values (<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 operation completed successfully.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_ACCESS_DENIED</p>
  <p>0x00000005</p>
  </td>
  <td>
  <p>Access is denied.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_INVALID_LEVEL</p>
  <p>0x0000007C</p>
  </td>
  <td>
  <p>The information level is invalid.</p>
  </td>
 </tr><tr>
  <td>
  <p>ERROR_MORE_DATA</p>
  <p>0x000000EA</p>
  </td>
  <td>
  <p>More entries are available. The <i>UserInfo</i> buffer
  was not large enough to contain all the entries. </p>
  </td>
 </tr></tbody></table>
</dd></dl><p>Any other return value MUST conform to the error code
requirements in <b>Protocol Details</b> (section <span><a href="aeea622a-ea3e-40cc-a9b1-b4a2a3b2bf6b" data-linktype="relative-path">3</a></span>).</p><p>The server (2) SHOULD<a id="Appendix_A_Target_35"></a><a aria-label="Product behavior note 35" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_35" data-linktype="relative-path">&lt;35&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>If the <b>Level</b> member of the <b>WKSTA_USER_ENUM_STRUCT</b>
structure passed in the <i>UserInfo</i> parameter does not equal 0x00000000 or
0x00000001, the server MUST fail the call.</p><p>If the <b>Level</b> member equals 0x00000000, the server
MUST return an array of the names of users currently logged on the computer by
filling the <b>WKSTA_USER_INFO_0_CONTAINER</b> structure (section 2.2.5.14) in
the <b>WkstaUserInfo</b> field of the <i>UserInfo</i> parameter. </p><p>If the <b>Level</b> member equals 0x00000001, the server
MUST return an array of the names and <span><a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_b0276eb2-4e65-4cf1-a718-e0920a614aca" data-linktype="relative-path">domain</a></span> details of
each user currently logged on the computer, and a list of <b>OtherDomains</b>
(section <span><a href="0929c3a5-0424-420e-a35c-a6844a7b848f" data-linktype="relative-path">3.2.1.3</a></span>) in the
computer.</p><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. Otherwise, if the <i>PreferredMaximumLength</i>
is insufficient to hold all the entries, then the server MUST return the
maximum number of entries that fit in the <i>UserInfo</i> buffer and return
ERROR_MORE_DATA.</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
currently logged on users.<a id="Appendix_A_Target_36"></a><a aria-label="Product behavior note 36" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_36" data-linktype="relative-path">&lt;36&gt;</a></p>
</li><li><p><span><span> 
</span></span>If the <i>ResumeHandle</i> parameter points to a non-zero value,
the server MUST continue enumeration based on the value of <i>ResumeHandle</i>.
The server is not required to maintain any state between calls to the
NetrWkstaUserEnum method.</p>
</li><li><p><span><span> 
</span></span>If the client specifies a <i>ResumeHandle</i>, and if the server
returns ERROR_MORE_DATA, the server MUST set the value to which <i>ResumeHandle</i>
points to an implementation-specific value that allow the server to continue
with this enumeration on a subsequent call to this method, with the same value
for <i>ResumeHandle</i>. </p>
</li></ul><p>The server is not required to maintain any state between
calls to the NetrWkstaUserEnum method. 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></div>