Workflow Soluiton

 View Only

How To Get DNS Name And IP Address From Remote Computer Using Workflow Solution  

Jan 08, 2010 10:48 AM

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
001.png

2. Double Click To Edit The Component and Click Next
002.png

3. Enter the Result Variable Name (I used v_CurrentComputerName) and select Text as the Result Variable Type and Click Next
003.png

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)
004.png

8. Click Finish
005.png

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

001.png
2. Double Click To Edit The Component and Click Next
002.png

3. Enter the Result Variable Name (I used v_CurrentComputerIP) and select Text as the Result Variable Type
006.png

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)
007.png

8. Click Finish
005.png

You may now test your results.  Be sure to use the variable named v_CurrentComputerIP

Enjoy!

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jan 07, 2011 02:05 PM

Currently using it on my Windows 7 environment.

  1. Are you by any chance using IPV6 on your Windows 7 environment?
  2. If you are, are you using only IPV6 or both IPV6 and IPV4?
  3. Is your Windows 7 firewall enabled?
  4. Have you tried checking your firewall settings?

Dec 03, 2010 09:09 AM

 

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?

Jun 23, 2010 11:57 AM


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.

Apr 07, 2010 02:41 PM


I've been looking for how to do this for a while. Thanks for the post!

Mar 16, 2010 08:23 PM


Thank you so much for writing this acticle, this really helped me out.

Mar 15, 2010 01:25 PM

Found my own answer.  You have to add http://servername:8088 to your trusted site and then it wil work fine in IE8.

Mar 11, 2010 02:45 PM

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.
WorkflowError.png

This works fine if you are running IE6 or IE7.

Related Entries and Links

No Related Resource entered.