<div class="content" name="RpcWinStationConnect" uuid="88a127d1-80de-407a-a95b-9fb9d45e29d4"><p>The <b>RpcWinStationConnect</b> method connects a user&#39;s <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_b416f72e-cf04-4d80-bf93-f5753f3b0998" data-linktype="relative-path">terminal
server</a></span> 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 <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 client indicated by <i>ConnectLogonId</i> MUST have
WINSTATION_DISCONNECT permission. Similarly, <i>TargetLogonId</i> MUST have
WINSTATION_CONNECT and WINSTATION_DISCONNECT permissions. For each of the
aforementioned permissions, 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.<a id="Appendix_A_Target_180"></a><a aria-label="Product behavior note 180" href="7ce7f717-461b-4f18-9829-6690168c7707#Appendix_A_180" data-linktype="relative-path">&lt;180&gt;</a></p><dl>
<dd>
<div><pre> 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
 );
</pre></div>
</dd></dl><p><b>hServer: </b>Handle to the server object. This is
of type <span><a href="49484cdf-2feb-4de9-a588-5d01cf8995dc" data-linktype="relative-path">SERVER_HANDLE</a></span>. The <i>hServer</i>
argument MUST be obtained from a previous call to <span><a href="fd6f339d-f5dd-452c-a9a9-ec753c22a36a" data-linktype="relative-path">RpcWinStationOpenServer</a></span>.</p><p><b>pResult: </b>If the call was successful, this
parameter MUST be STATUS_SUCCESS (0x00000000); otherwise, it MUST be an
implementation-specific negative value.</p><p><b>ClientLogonId: </b> The session ID of the caller
of this method.</p><p><b>ConnectLogonId: </b>The ID of the session from
which the connection is being made. This MUST be the same as <i>ClientLogonId</i>
and MUST be an existing session ID. The user MUST be logged on. To indicate the
current session, this MUST be LOGONID_CURRENT.</p><p><b>TargetLogonId: </b> The session ID of the session
to which the connection is being made. Cannot be the same as <i>ConnectLogonId</i>
and MUST be an existing session ID.</p><p><b>pPassword: </b> The password of <i>TargetLogonId</i>&#39;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 <i>TargetLogonId</i>&#39;s session.</p><p><b>PasswordSize: </b>The length of the string <i>pPassword</i>
in characters including the terminating NULL character.</p><p><b>Wait: </b> TRUE indicates to wait for the
connection to complete, FALSE otherwise.<a id="Appendix_A_Target_181"></a><a aria-label="Product behavior note 181" href="7ce7f717-461b-4f18-9829-6690168c7707#Appendix_A_181" data-linktype="relative-path">&lt;181&gt;</a></p><p><b>Return Values: </b> Returns TRUE if the call
succeeded, or FALSE if the method failed. On failure, <i>pResult</i> indicates
the failure status code.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x01 TRUE</td>
  <td>Successful completion.</td>
 </tr><tr>
  <td>0x00 FALSE</td>
  <td>Method call failed.</td>
 </tr></tbody></table>
</dd></dl><p> </p></div>