<div class="content" name="RpcGetAllSessionsEx" uuid="3f724979-25cd-41d8-9829-244f4425f9c6"><p>The <b>RpcGetAllSessionsEx</b> method returns a pointer of
type <span><a href="0a3f7e7b-03f8-4f62-a65f-c2d670bb3173" data-linktype="relative-path">PEXECENVDATAEX</a></span>,
which points to the list of sessions currently running on the terminal server
and the sessions running on various virtual machines hosted by the server. No
special permissions are required to call this method. However, only sessions
for which the caller has WINSTATION_QUERY permission are enumerated. The method
checks whether the caller has WINSTATION_QUERY permission (section <span><a href="4507e852-be3d-45b6-bc47-8ca0b552c94d" data-linktype="relative-path">3.1.1</a></span>)
by setting it as the Access Request mask, and skips the sessions for which the
caller does not have the permission.<a id="Appendix_A_Target_157"></a><a aria-label="Product behavior note 157" href="7ce7f717-461b-4f18-9829-6690168c7707#Appendix_A_157" data-linktype="relative-path">&lt;157&gt;</a></p><dl>
<dd>
<div><pre> HRESULT RpcGetAllSessionsEx(
   [in] handle_t hBinding,
   [in] ULONG Level,
   [out, size_is(,*pcEntries)] PEXECENVDATAEX* ppSessionData,
   [out] ULONG* pcEntries
 );
</pre></div>
</dd></dl><p><b>hBinding: </b>The <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a></span> binding <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a></span>.
For more information, see <span><a href="https://go.microsoft.com/fwlink/?LinkId=93771" data-linktype="external">[MSDN-RPCBIND]</a></span>.</p><p><b>Level: </b>The level of information requested.
This field MUST be set to 1. If the server does not support the level
requested, it will set the level to the maximum supported level and return an
implementation-specific nonzero value.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>1</td>
  <td>The union ExecEnvDataEx has the EXECENVDATAEX_LEVEL1 structure.</td>
 </tr></tbody></table>
</dd></dl><p><b>ppSessionData: </b>A pointer of type
PEXECENVDATAEX (section 2.2.2.7), which points to the list of
sessions currently running on the terminal server and the sessions running on
virtual machines hosted by the server.</p><p><b>pcEntries: </b>The number of sessions currently
running on the terminal server and returned in the <b>ppSessionData</b>
structure.</p><p><b>Return Values: </b>The method MUST return S_OK (0x00000000)
on success; otherwise, it MUST return an implementation-specific negative
value.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 S_OK</td>
  <td>Successful completion.</td>
 </tr></tbody></table>
</dd></dl><p> </p></div>