3.7.4.1.11 RpcWinStationConnect (Opnum 10)

The RpcWinStationConnect method connects a user's terminal server client from a given terminal server session to a different terminal server session. If there is a user connected to the client session, it will be disconnected at the end of this call. If the method succeeds, the state of the session is State_Active as defined in the WINSTATIONSTATECLASS enumeration (section 2.2.1.9).

The client indicated by ConnectLogonId MUST have WINSTATION_DISCONNECT permission. Similarly, TargetLogonId MUST have WINSTATION_CONNECT and WINSTATION_DISCONNECT permissions. For each of the aforementioned permissions, the method checks whether the caller has the permission (section 3.1.1) by setting the Access Request mask to the specific permission, and fails if the caller does not have the permission.<178>

 BOOLEAN RpcWinStationConnect(
   [in] SERVER_HANDLE hServer,
   [out] DWORD* pResult,
   [in] DWORD ClientLogonId,
   [in] DWORD ConnectLogonId,
   [in] DWORD TargetLogonId,
   [in, size_is(PasswordSize)] PWCHAR pPassword,
   [in, range(0, 1024)] DWORD PasswordSize,
   [in] BOOLEAN Wait
 );

hServer: Handle to the server object. This is of type SERVER_HANDLE. The hServer argument MUST be obtained from a previous call to RpcWinStationOpenServer.

pResult: If the call was successful, this parameter MUST be STATUS_SUCCESS (0x00000000); otherwise, it MUST be an implementation-specific negative value.

ClientLogonId:  The session ID of the caller of this method.

ConnectLogonId: The ID of the session from which the connection is being made. This MUST be the same as ClientLogonId and MUST be an existing session ID. The user MUST be logged on. To indicate the current session, this MUST be LOGONID_CURRENT.

TargetLogonId:  The session ID of the session to which the connection is being made. Cannot be the same as ConnectLogonId and MUST be an existing session ID.

pPassword:  The password of TargetLogonId's session. The password MUST be valid. The password MAY be NULL if the same user is making the call as the user logged on to TargetLogonId's session.

PasswordSize: The length of the string pPassword in characters including the terminating NULL character.

Wait:  TRUE indicates to wait for the connection to complete, FALSE otherwise.<179>

Return Values:  Returns TRUE if the call succeeded, or FALSE if the method failed. On failure, pResult indicates the failure status code.

Return value/code

Description

0x01

TRUE

Successful completion.

0x00

FALSE

Method call failed.