<div class="content" name="TsProxySetupReceivePipe" uuid="8147cb81-042f-48a3-a7ff-9f12ab73e048"><p>The TsProxySetupReceivePipe method is used for data transfer
from the RDG <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a> to
the RDG <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a>. The RDG
server MUST create an <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a>
<a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_6b6d4ea2-97a7-49ee-84fa-ab4ce26579aa" data-linktype="relative-path">out pipe</a> upon receiving
this method call from the RDG client. This call bypasses the <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_9ebf9540-2c31-43bc-bc56-4a932faabf2d" data-linktype="relative-path">NDR</a> and hence, the RPC
runtime MUST NOT perform a strict NDR data consistency check for this method.
Refer to section <a href="e7afc9b3-f5a6-45bb-aff2-787bf366cac2" data-linktype="relative-path">3.6.5</a>
for details on NDR-bypassing. Section <a href="473d326f-e72e-4769-9268-95f429364b8f" data-linktype="relative-path">3.6.5.4</a> and section <a href="369143bc-a72e-4508-9bcf-0eb901058583" data-linktype="relative-path">3.6.5.5</a> give details on
wire representation of data for responses to TsProxySetupReceivePipe. The out
pipe MUST be created by the RDG server in the same manner as NDR creates it for
a call.<a id="Appendix_A_Target_49"></a><a aria-label="Product behavior note 49" href="e63f32e6-39ec-43c8-aae5-3ffa1c408966#Appendix_A_49" data-linktype="relative-path">&lt;49&gt;</a> The RDG server MUST use this
out pipe and Stub Data field in RPC response PDUs to send all data from the
target server to the RDG client on the <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_9964c8b0-1d25-4e8e-9dd1-4a51577698f5" data-linktype="relative-path">channel</a>. The RDG client
MUST use this out pipe to pull data from the <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_3657ab68-5a60-4cee-8082-dfc2e67435e9" data-linktype="relative-path">target server</a> on the
channel. On connection disconnect, the RDG server MUST send the following on
the pipe: A <a href="../ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2" data-linktype="relative-path">DWORD</a>
return code in an RPC response PDU and set the PFC_LAST_FRAG bit in the <b>pfc_flags</b>
field of the RPC response PDU. The pipe close is indicated when the
PFC_LAST_FRAG bit is set in the <b>pfc_flags</b> field of the RPC response PDU.
When the RDG client sees that the PFC_LAST_FRAG bit is set in the <b>pfc_flags</b>
field of the RPC response PDU, it MUST interpret the 4 bytes Stub Data as the
return code of TsProxySetupReceivePipe. For a description of RPC response PDU, <b>pfc_flags</b>,
PFC_LAST_FRAG, and Stub Data, refer to sections 12.6.2 and 12.6.4.10 in <a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a>. The RDG client
and RDG server MUST negotiate a separate out pipe for each channel. Out pipes
MUST NOT be used or shared across channels.<a id="Appendix_A_Target_50"></a><a aria-label="Product behavior note 50" href="e63f32e6-39ec-43c8-aae5-3ffa1c408966#Appendix_A_50" data-linktype="relative-path">&lt;50&gt;</a></p><p>As long as the channel is not closed, the RPC and Transport
layer guarantee that any data that is sent by the RDG server reaches the RDG
client. RPC and Transport layer also ensure that the data is delivered to the
RDG client in the order it was sent by the RDG server.</p><p>After the call reaches the RDG server, the connection MUST
transition to Pipe Created state after setting up the out pipe.</p><p>Prerequisites: The connection MUST be in Channel Created
state. If this is called in any other state, then the behavior is undefined.</p><p>Sequential Processing Rules:</p><ol><li><p><span>    </span>If some
unexpected error occurs in the following process, the RDG server MUST return
HRESULT_CODE(E_PROXY_INTERNALERROR).</p>
</li><li><p><span>    </span>If the RDG
server is implementing the Connection Timer, then if TsProxySetupReceivePipe is
called after the Connection Timer has expired, the RDG server MUST return
ERROR_OPERATION_ABORTED; otherwise, the Connection Timer MUST be stopped.</p>
</li><li><p><span>    </span>The RDG server
MUST extract the channel context <a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a> from <i>pRpcMessage</i>
parameter. For the <i>pRpcMessage</i> format, refer to <a href="b37b7649-f84a-486c-a688-5488b8d69a79" data-linktype="relative-path">RDG Client to RDG Server
Packet Format (section 2.2.9.4.1)</a>.</p>
</li><li><p><span>    </span>The RDG server
MUST verify that the channel context handle is not NULL. Otherwise, it MUST
return ERROR_ACCESS_DENIED.</p>
</li><li><p><span>    </span>If the RDG
server is configured such that the connections are allowed only to a resource
that allows policy exchanges between the RDG server and the target server, and
the target server does not support the same, then the RDG server MUST return
HRESULT_CODE(E_PROXY_SDR_NOT_SUPPORTED_BY_TS).</p>
</li><li><p><span>    </span>If connection to
the target server is not set up in <a href="99458693-7c7e-45fb-abf8-2328439a4b35" data-linktype="relative-path">TsProxyCreateChannel</a> call,
then the RDG server MUST try to connect to the target server by each name in
the <b>Target server names</b> array until it succeeds or until the array is
traversed completely. If connection fails for all target server names, it MUST
return HRESULT_CODE(E_PROXY_TS_CONNECTFAILED).<a id="Appendix_A_Target_51"></a><a aria-label="Product behavior note 51" href="e63f32e6-39ec-43c8-aae5-3ffa1c408966#Appendix_A_51" data-linktype="relative-path">&lt;51&gt;</a></p>
</li><li><p><span>    </span>The RDG server
MUST set up an out pipe to send data received from the target server to the RDG
client.</p>
</li><li><p><span>    </span>The connection
MUST transition to Pipe Created state.</p>
</li><li><p><span>    </span>The RDG server
MUST start receiving data from the target server and stream the same to the RDG
client. This process MUST be continued until one of the following events
occurs.</p>
<ol><li><p><span>   
</span>If the Session Timeout Timer expires and the <b>TimeoutAction</b> ADM
element is set to &#34;disconnect on session timeout&#34; RDG server: </p>
<ol><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> contains <a href="9894223f-99c7-49d9-a79d-3c9670d500f5" data-linktype="relative-path">TSG_NAP_CAPABILITY_IDLE_TIMEOUT</a>,
then the RDG server MUST disconnect the session by sending the final response
of the TsProxySetupReceivePipe method with the
HRESULT_CODE(E_PROXY_SESSIONTIMEOUT) error code.</p>
</li><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> does not contain
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
session by sending the final response of the TsProxySetupReceivePipe method
with the HRESULT_CODE(E_PROXY_CONNECTIONABORTED) error code.</p>
</li></ol></li><li><p><span>   
</span>If the session timeout timer expires and the <b>TimeoutAction</b> ADM
element is set to &#34;<a href="76796f19-9e6f-48b9-8b8f-4ef9f197056b#gt_a010756e-fca1-42cc-94a6-9a8195016b54" data-linktype="relative-path">reauthentication</a>
on session timeout&#34;, the RDG server initiates a reauthentication with the
client and starts the reauthentication timer, as explained in section <a href="b0c72357-ea2d-4cf5-8761-b51620c9e50d" data-linktype="relative-path">3.2.7.1</a>. After the
reauthentication timer expires, the RDG server MUST check the value of <b>Reauthentication
Status</b> ADM element.</p>
<ul><li><p><span><span> 
</span></span>If the ADM element <b>Reauthentication Status</b> is set to NONE:</p>
<ol><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> contains
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_REAUTH_AUTHN_FAILED).</p>
</li><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> does not contain
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_CONNECTIONABORTED).</p>
</li></ol></li><li><p><span><span> 
</span></span>If the ADM element <b>Reauthentication Status</b> is set to
AuthenticationCompleted:</p>
<ol><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> contains
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_REAUTH_CAP_FAILED).</p>
</li><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> does not contain TSG_NAP_CAPABILITY_IDLE_TIMEOUT,
then the RDG server MUST disconnect the connection with
HRESULT_CODE(E_PROXY_CONNECTIONABORTED).</p>
</li></ol></li><li><p><span><span> 
</span></span>If the ADM element <b>Reauthentication Status</b> is set to
UserAuthorizationCompletedButQurantineFailed:</p>
<ol><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> contains
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_REAUTH_NAP_FAILED).</p>
</li><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> does not contain
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_CONNECTIONABORTED).</p>
</li></ol></li><li><p><span><span> 
</span></span>If the ADM element <b>Reauthentication Status</b> is set to
UserAuthorizationCompleted:</p>
<ol><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT,
then the RDG server MUST disconnect the connection with
HRESULT_CODE(E_PROXY_REAUTH_RAP_FAILED).</p>
</li><li><p><span>    </span>If the ADM
element <b>Negotiated Capabilities</b> does not contain
TSG_NAP_CAPABILITY_IDLE_TIMEOUT, then the RDG server MUST disconnect the
connection with HRESULT_CODE(E_PROXY_CONNECTIONABORTED).</p>
</li></ol></li><li><p><span><span> 
</span></span>If the ADM element <b>Reauthentication Status</b> is set to
ResourceAuthorizationCompleted, the RDG server MUST start the Session Timeout
Timer and MUST reset the ADM element <b>Reauthentication Status</b> to NONE.</p>
</li></ul></li><li><p><span>   
</span>If the target server unexpectedly closes the connection between the RDG
server and the target server, the RDG server MUST return ERROR_BAD_ARGUMENTS.</p>
</li><li><p><span>   
</span>If the RDG server administrator forcefully disconnects the connection,
the RDG server MUST return HRESULT_CODE(E_PROXY_CONNECTIONABORTED).</p>
</li><li><p><span>   
</span>If the connection gets disconnected either by the RDG client or the RDG
server, or by an unknown error, the RDG server MUST send the corresponding
error code to the RDG client in the final response, as specified in <a href="e606f3a9-70d8-4f66-b7ab-25e17e299d08" data-linktype="relative-path">RDG Server to RDG Client
Packet Format for Final Response (section 2.2.9.4.3)</a>.</p>
</li></ol><div><pre> DWORD TsProxySetupReceivePipe(
   [in, max_is(32767)] byte pRpcMessage[]
 );
</pre></div>
</li></ol><p><b>pRpcMessage: </b>The protocol data between RDG
client and RDG server MUST be decoded as specified in section <a href="850502e1-4c17-430c-acd5-a31d83747895" data-linktype="relative-path">2.2.9.4</a>. RPC stub
information is specified in <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>
sections <a href="../ms-rpce/1644e4e6-1340-4d9a-9258-c62ff87e9e55" data-linktype="relative-path">1.1</a>
and <a href="../ms-rpce/4c239820-4cdf-413c-b0c5-2d07465d55a6" data-linktype="relative-path">1.5</a>.</p><p><b>Return Values: </b>The method MUST return
ERROR_GRACEFUL_DISCONNECT on success, that is, if the RDG client gracefully
disconnects the connection by calling <a href="6c537074-326f-4e28-b4eb-345f35404e7f" data-linktype="relative-path">TsProxyCloseChannel</a>. Other
failures MUST be one of the codes listed. The client MAY interpret failures in
any way it deems appropriate. See section <a href="38d327b5-e131-4fa3-9a46-7e3ac20e0a4f" data-linktype="relative-path">2.2.6</a> for details on these
errors.</p><dl>
<dd>
<p>The error DWORD value is always sent, when the
receive pipe closes down. The receive pipe will always close down when a
disconnect takes place. </p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value</p>
   </th>
   <th>
   <p>State transition</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>ERROR_ACCESS_DENIED (0x00000005)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned either if this method is called before TsProxyCreateChannel or if the Channel Context Handle ADM element is NULL. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_INTERNALERROR) (0x000059D8)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when an unexpected error occurs in TsProxySetupReceivePipe. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_TS_CONNECTFAILED) (0x000059DD)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when the RDG server fails to connect to target server. It is returned in an rpc_fault packet.&lt;52&gt; The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_SESSIONTIMEOUT) (0x000059F6)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned by RDG server if a session timeout occurs and &#34;disconnect on session timeout&#34; is configured at the RDG server and the ADM element Negotiated Capabilities contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_REAUTH_AUTHN_FAILED) (0x000059FA)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when a reauthentication attempt by the client has failed because the user credentials are no longer valid and the ADM element Negotiated Capabilities contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_REAUTH_CAP_FAILED) (0x000059FB)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when a reauthentication attempt by the client has failed because the user is not authorized to connect through the RDG server anymore and the ADM element Negotiated Capabilities contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_REAUTH_RAP_FAILED) (0x000059FC)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when a reauthentication attempt by the client has failed because the user is not authorized to connect to the given end resource anymore and the ADM element Negotiated Capabilities contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_CONNECTIONABORTED) (0x000004D4)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when the following happens:  The RDG server administrator forcefully disconnects the connection.  Or when the ADM element Negotiated Capabilities doesn&#39;t contain TSG_NAP_CAPABILITY_IDLE_TIMEOUT and any one of the following happens: Session timeout occurs and disconnect on session timeout is configured at the RDG server. Reauthentication attempt by the client has failed because the user credentials are no longer valid. Reauthentication attempt by the client has failed because the user is not authorized to connect through the RDG server anymore. Reauthentication attempt by the client has failed because the user is not authorized to connect to the given end resource anymore. Reauthentication attempt by the RDG client has failed because the health of the user&#39;s computer is no longer compliant with the RDG server configuration.  The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_SDR_NOT_SUPPORTED_BY_TS) (0x000059FD)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>The RDG server is capable of exchanging policies with some target servers. The RDG server MAY be configured to allow connections to only target servers that are capable of policy exchange. If such a setting is configured and the target server is not capable of exchanging policies with the RDG server, this error will be returned. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>ERROR_GRACEFUL_DISCONNECT (0x000004CA)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when the connection is disconnected gracefully by the RDG client calling TsProxyCloseChannel.</td>
 </tr><tr>
  <td>HRESULT_CODE(E_PROXY_REAUTH_NAP_FAILED) (0x00005A00)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when a reauthentication attempt by the RDG client has failed because the user&#39;s computer&#39;s health is no longer compliant with the RDG server configuration and the ADM element Negotiated Capabilities contains TSG_NAP_CAPABILITY_IDLE_TIMEOUT. The RDG client MUST end the protocol when this error is received.</td>
 </tr><tr>
  <td>ERROR_OPERATION_ABORTED(0x000003E3)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when the call to TsProxySetupReceivePipe is received after the Connection Timer has expired.</td>
 </tr><tr>
  <td>ERROR_BAD_ARGUMENTS(0x000000A0)</td>
  <td>The connection MUST transition to Tunnel Close Pending state.</td>
  <td>Returned when the target server unexpectedly closes the connection between the RDG server and the target server.</td>
 </tr></tbody></table>
</dd></dl><p> </p></div>