private void SetProxySetting(IcaFile icaFile, string proxySettingName, string value)
 {
     // Set proxy settings in both the WFClient and Application sections
     // to avoid possible problems in older clients.
     icaFile.SetPropertyValue("WFClient", proxySettingName, value);
     icaFile.SetPropertyValue(IcaFile.ApplicationSection, proxySettingName, value);
 }
Esempio n. 2
0
        public string Modify(string valueToModify, CustomizationContextData context)
        {
            var    icadetails  = new IcaFile(valueToModify);
            string appLaunched = icadetails.GetPropertyValue(IcaFile.ApplicationSection, "InitialProgram"); // or "Title" for friendly Name

            Tracer.TraceInfo("User {0} launches app: {1}", context.UserIdentity.Name, appLaunched);

            // We're not changing the ica file, so just return the value originally supplied
            return(valueToModify);
        }
        public string Modify(string valueToModify, CustomizationContextData context)
        {
            var icadetails = new IcaFile(valueToModify);

            // If the request is detected as having come via a gateway, then treat as remote access:
            bool isRemoteAccess = context.RequestGateway != null;

            icadetails.SetPropertyValue(IcaFile.ApplicationSection, "SFRAllowed", isRemoteAccess ? "Off" : "On");

            // get modified string back from helper breakdown class.
            string modifiedIcaFile = icadetails.ToString();

            Tracer.TraceInfo("Launch Customisation: check modifications to ICA File");
            Tracer.TraceInfo(modifiedIcaFile);
            return(modifiedIcaFile);
        }
        public string Modify(string originalIcaFileContent, CustomizationContextData context)
        {
            var icaFile = new IcaFile(originalIcaFileContent);

            // Get the client ip address (detected from the request HTTP headers)
            var clientIpAddress = context.DeviceInfo.DetectedAddress;

            if (clientsNeedingSocksProxyPattern.IsMatch(clientIpAddress))
            {
                // the client ip address matches the range of addresses for which we want the client to use a SOCKS proxy.
                SetProxySetting(icaFile, "ProxyType", "Socks");
                SetProxySetting(icaFile, "ProxyHost", "socksproxy.mycompany.com:1080");
            }
            else
            {
                // otherwise let the client auto detect the proxy server.
                SetProxySetting(icaFile, "ProxyType", "Auto");
            }

            string customizedIcaContent = icaFile.ToString();

            return(customizedIcaContent);
        }