I am working on a launcher tool for Citrix XenApp that can not only connect to a published application or published desktop but can also leverage Citrix Workspace Control to reconnect to disconnected and/or active sessions.

There doesn't seem to be any sdk that exposed the data we need so I am trying to reproduce what the Citrix online plugi-in does.

I used a HTTP monitoring tool to capture the traffic between the Online plug-in and the Web Interface. First the online plug-in will retrieve the config.xml from the server specified via the Change Server option:

What is the address of the server hosting your published resources? | Server Address | Example: servername (for non-secure connections) | https://servername (for secure connections)

The config.xml is a rather large xml file, the interesting part is the Request.Enumeration (I left out the other data):

text Download
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PNAgent_Configuration SYSTEM "PNAgent.dtd"[]>
<PNAgent_Configuration xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
    <Request>
        <Enumeration>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/enum.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_enum.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_enum.aspx</Integrated_Location>
            <Refresh>
                <OnApplicationStart modifiable="false" forcedefault="true">true</OnApplicationStart>
                <OnResourceRequest modifiable="false" forcedefault="true">false</OnResourceRequest>
                <Poll modifiable="false" forcedefault="true">
                    <Enabled>true</Enabled>
                    <Period>6</Period>
                </Poll>
            </Refresh>
        </Enumeration>
        <Resource>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/launch.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_launch.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_launch.aspx</Integrated_Location>
        </Resource>
        <Reconnect>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/reconnect.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_reconnect.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_reconnect.aspx</Integrated_Location>
        </Reconnect>
        <Change_Password>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/change_password.aspx</Location>
        </Change_Password>
        <MachineControl>
            <Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/desktopControl.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_desktopControl.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_desktopControl.aspx</Integrated_Location>
        </MachineControl>
    </Request>
</PNAgent_Configuration>

From this xml data, the enum.aspx url is taken and another HTTP post is sent to that url which contains the following xml in my case:

text Download
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"><NFuseProtocol version="4.6">
	<RequestReconnectSessionData>
		<Credentials>
			<UserName>administrator</UserName>
			<Password encoding="ctx1">NFHALEBBMHGCLEBBMDGGKMAJNOHLLKBP</Password>
			<Domain type="NT">CONTOSO</Domain>
		</Credentials>
		<ClientName>REMLAPTOP</ClientName>
		<ClientName>REMLAPTOP</ClientName>
		<ServerType>win32</ServerType>
		<ClientType>ica30</ClientType>
		<SessionType>disconnected</SessionType>
		<SessionType>active</SessionType>
	</RequestReconnectSessionData>
</NFuseProtocol>

Notice that the password is encoded so if we want to replicate the HTTP post data we need to be able to encode (and perhaps decode) the password.

The decoding seems to be named Ctx1 but I couldn't find any information on how it should be encoded so I had to find it out myself.

I wrote a tool that that can encode and decode the passwords and I suspect the password decoding is the same as used for storing passwords in ica files (I haven't checked that yet...):

Encrypt | Decrypt Password | Hash | Citrix | Ctx1

The tool can be downloaded below.

CtxPass.zip