3.3.4.3.10 RpcGetAllSessions (Opnum 10)

The RpcGetAllSessions method returns a pointer of type PEXECENVDATA, 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 3.1.1) by setting it as the Access Request mask, and skips the sessions for which the caller does not have the permission.<153>

 HRESULT RpcGetAllSessions(
   [in] handle_t hBinding,
   [in, out] ULONG* pLevel,
   [out, size_is(,*pcEntries)] PEXECENVDATA* ppSessionData,
   [out] ULONG* pcEntries
 );

hBinding: The RPC binding handle. For more information, see [MSDN-RPCBIND].

pLevel: The level of information requested. This field MUST be set to the supported values of 1 or 2. 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.

Value

Meaning

1

The union ExecEnvData will have the EXECENVDATA_LEVEL1 structure.

2

The union ExecEnvData will have the EXECENVDATA_LEVEL2 structure.

ppSessionData: A pointer of type PEXECENVDATA (section 2.2.2.6), which points to the list of sessions currently running on the terminal server and the session running on virtual machines hosted by the server.<154>

pcEntries: The number of sessions currently running on the terminal server and returned in the ppSessionData structure.

Return Values: The method MUST return S_OK (0x00000000) on success; otherwise, it MUST return an implementation-specific negative value.

Return value/code

Description

0x00000000

S_OK

Successful completion.