<div class="content" name="RpcConnect" uuid="b57917b9-b006-48b3-ae64-016771c25bee"><p>The RpcConnect method reconnects a session <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a></span>
returned by <span><a href="56ede88b-913b-4911-9540-389fddf879e5" data-linktype="relative-path">RpcOpenSession</a></span> to
another specified session on the <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_b416f72e-cf04-4d80-bf93-f5753f3b0998" data-linktype="relative-path">terminal server</a></span>.
This method MUST be called after RpcOpenSession. If the method succeeds, the
state of the session is State_Active as defined in the <b>WINSTATIONSTATECLASS</b>
enumeration (section <span><a href="b619d8aa-4e8a-4716-954e-a4d596ed37f8" data-linktype="relative-path">2.2.1.9</a></span>).</p><p>The caller MUST have WINSTATION_CONNECT permission to
connect the current session and the caller MUST have WINSTATION_DISCONNECT
permission to disconnect the target session. For each aforementioned required
permission, the method checks whether the caller has the permission (section <span><a href="4507e852-be3d-45b6-bc47-8ca0b552c94d" data-linktype="relative-path">3.1.1</a></span>)
by setting the Access Request mask to the specific permission, and fails if the
caller does not have the permission.</p><dl>
<dd>
<div><pre> HRESULT RpcConnect(
   [in] SESSION_HANDLE hSession,
   [in] LONG TargetSessionId,
   [in, string] WCHAR* szPassword
 );
</pre></div>
</dd></dl><p><b>hSession: </b>The handle to a session returned by
RpcOpenSession. This is of type <span><a href="08a45954-8173-43c6-aa10-7aeda48e8dc2" data-linktype="relative-path">SESSION_HANDLE</a></span>.</p><p><b>TargetSessionId: </b>The identifier of the session
on the terminal server to which to reconnect the session handle. This session
MUST be present on the terminal server or this call will fail.</p><p><b>szPassword: </b>The password of the user connected
to the current session. This is an optional field. If not specified, the
terminal server will impersonate the current user, making the call and checking
whether it has permission to disconnect the current session.</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>