Posted by Davy Witvrouwen on 18/01/2012.
Symantec Workflow projects run on a workflow server and are published through IIS. Getting the hostname from a workstation running the project can be challenging. In most circumstances, you can populate this parameter in your project through a quite easy fail-proof procedure.
When creating workflow applications in your environment, there is a good chance you’ll need to use the hostname of the computer where a user is initiating the application somewhere in your process.
E.g., if you are building an automated software request application, the workflow process might want to know to which computer to deliver the requested software. In most cases, this is the workstation where the request was launched.
Because workflow applications are running on the workflow server, using a well-known scripting
variable such as %computername% in your project is useless, since this would be returning the hostname of the workflow server itself. For security reasons, server-side scripting is the preferred method to use in workflow applications.
The most common way to get a client computer name in your project is to create a variable and use a scripting language to read out server variables from the current IIS session. Here is an example of a commonly used C# code to accomplish this:
| System.Net.Dns.GetHostEntry(System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName |
While the code above is a proven method to read out the IP address of a client session and then translating this IP to a hostname through DNS query, I found in some circumstances the result is not always 100% correct. In fact, the result is only as good as the reliability of your DNS infrastructure. Also when using a proxy server, this method cannot be used as the proxy servers’ hostname will be returned.
If you are deploying a workflow application to your workstations through the means of a shortcut or start menu entry, you can allow your project to receive the computer name in an alternative, easy and fail-proof method by simply passing the computer name when starting the application.
You only need to perform 2 steps to accomplish this:
1. In your workflow project on the primary model add a text variable as an input data parameter.
2. Distribute a shortcut or start menu item to your clients by using Symantec Software Delivery or Group Policy (preferences) with the following target: http://<WFservername>/<ApplicationName>/StartTaskDialog.aspx?Computer_Name=%Computername%
By distributing the target above the shortcut or start menu item itself is placed on the clients with the Windows environment variable %computername% already correctly translated to the clients’ hostname. When the user now launches the application, the parameter is passed to the workflow project’s primary model.
From now on you can use the ‘Computer_Name’ variable throughout your complete workflow process populated with the correct client’s hostname.