I found myself in the same situation as many when using the "GetComputerInfo" component when it returned the Workflow server DNS Name and IP address instead of the current/remote user's. Here are two really great and simple ways to retrieve DNS name and IP using the "Code (Script) Component".
1. Use the Code (Script) Component 2. Double Click To Edit The Component and Click Next 3. Enter the Result Variable Name (I used v_CurrentComputerName) and select Text as the Result Variable Type and Click Next 4. Select C Sharp as the Language (see image 4a below) 5. Under "Using namespaces (one per line):" type System (see image 4a below) 6. Under "Source code:" type the following code: (see image 4a below)
string result = System.Net.Dns.GetHostEntry(System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName; return result;
7. Click Next when done (4a) 8. Click Finish You may now test your results. Be sure to use the variable named v_CurrentComputerName
1. Use the Code (Script) Component
2. Double Click To Edit The Component and Click Next 3. Enter the Result Variable Name (I used v_CurrentComputerIP) and select Text as the Result Variable Type 4. Select C Sharp as the Language (see image 4b below) 5. Under "Using namespaces (one per line):" type System (see image 4b below) 6. Under "Source code:" type the following code: (see image 4b below)
string myHost = System.Net.Dns.GetHostEntry(System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName; string myIP = System.Net.Dns.GetHostEntry(myHost).AddressList[0].ToString(); return myIP;
7. Click Next when done (4b) 8. Click Finish You may now test your results. Be sure to use the variable named v_CurrentComputerIP Enjoy!
Currently using it on my Windows 7 environment.
Thanks for this nice post it really helped me further until I started testing on windows7! The computer name is correctly generated for XP en W2k3 but not on a windows7 where it gives me 192 as result. Where 192 is probably the first part of my ip address…
Is there someone who tested this on windows7 because I’m wondering if my problem is related to the code or to the enhanced security features in Windows 7?