How To Get DNS Name And IP Address From Remote Computer Using Workflow Solution
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".
Here is how you get the DNS Name:
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;
You may now test your results. Be sure to use the variable named v_CurrentComputerName
Here is how you get the IP Address:
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;
You may now test your results. Be sure to use the variable named v_CurrentComputerIP
Enjoy!
Comments
Error When running IE8
I get the following errors when I try and run the workflow on a computer running IE8 and sometimes I get this on IE7. Any Ideas. I'm only using the top one to get the computer name but I would assum it does the same thing for the IP.

This works fine if you are running IE6 or IE7.
Error When running IE8
Found my own answer. You have to add http://servername:8088 to your trusted site and then it wil work fine in IE8.
Thanks so much!
Thank you so much for writing this acticle, this really helped me out.
Awesome...
I've been looking for how to do this for a while. Thanks for the post!
Retrieving the computer name and ip address through a proxy
Does anyone know how to retrieve this through a proxy server? When using the code above it returns the name and ip of our proxy server instead of the client computer. I did some research and found that you need to change the ["remote_addr"] to ["http_x_forwarded_for"] but can't seem to make it work trying to implement it various ways. If anyone can help me out with this it would be greatly appreciated.
I like my beats fast and my bass down low
Doesn't work on Windows 7 ?!
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?
It does work on Windows 7
Currently using it on my Windows 7 environment.
Would you like to reply?
Login or Register to post your comment.