Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

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

Updated: 08 Jan 2010 | 7 comments
Andy Tous's picture
+3 5 Votes
Login to vote

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!

Comments

bricast's picture
11
Mar
2010
0 Votes 0
Login to vote

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

This works fine if you are running IE6 or IE7.

bricast's picture
15
Mar
2010
1 Vote +1
Login to vote

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.

lone_ranger's picture
16
Mar
2010
1 Vote +1
Login to vote

Thanks so much!

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

tracy.mcgee's picture
07
Apr
2010
1 Vote +1
Login to vote

Awesome...

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

Aryanos's picture
23
Jun
2010
0 Votes 0
Login to vote

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

Gohan's picture
03
Dec
2010
0 Votes 0
Login to vote

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?

Andy Tous's picture
07
Jan
2011
0 Votes 0
Login to vote

It does work on Windows 7

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?