4. – Connect to a RDP server with symlink
You need to create the server and symlink first on the gateway. You can use config.html or HTTP API to create a server on the gateway:
HTTP API:
http://gatewayAddress/SERVER?id=serverId&displayName=Name&server=192.168.1.117&gatewayPwd=21232f297a57a5a743894a0e4a801fc3&...
You only need to do this one and you can put other parameters into this URL, such user, pwd, performanceFlags etc.
Every time after user logged into your portal, you create a temporary symlink for this user using HTTP API:
http://gatewayAddress/SYMLINK?symlink=symlinkId&server=serverId&validTime=5m&gatewayPwd=passwordInGateway.conf&...
gatewayPwd is hexadecimal MD5 hash of the password which is configured in gateway.conf. This symlink will be invalid after 5 minutes.
You can also put other RDP parameter when creating the symlink, for example:
var url = 'http://gatewayAddress/SERVER?id=serverId&displayName=Name&server=192.168.1.117&gatewayPwd=21232f297a57a5a743894a0e4a801fc3¶meters=' + encodeURIComponent('user=' + userName + '&pwd=' + password);
Then you let the user connect to this symlink instead:
window.onload = function() {
var gateway = '192.168.12.111', //change this to your Spark gateway address
symlinkId = 'theSymlinkId',
displayName = 'serverName',
url = 'ws://' + gateway + '/RDP?symlink=' + symlinkId + + '&displayName=' + displayName;
var r = new svGlobal.Rdp(url);
r.addSurface(new svGlobal.LocalInterface());
r.run();
};
Expired symlink will not affect connected sessions.
Pros: server address and credentials are saved on the gateway side. User can only see a
symlink id which will be invalid in a short time. This method works with VPN or without VPN.
Cons: You may need to recreate the symlink for user if the symlink expired.