0

I'm working with angular5. And I want to fetch Ip Adress of User's PC. I have written a script for that, Which uses RTCPeerConnection. Script is working fine with chrome and firefox. But in IE RTCPeerConnection is not working. So I have Used ActiveXObject for the same. But I'm not sure how can I get User's IP using ActiveXObject

I'm getting User's PC name using this code.

var network = new ActiveXObject('WScript.Network');
var pcName = network.UserDomain; //User's Pc name

How can I get User's Ip using ActiveXObject? Is there any other way to find user's Ip when browser is Internet Explorer?

Ushma Joshi
  • 459
  • 6
  • 19
  • maybe this https://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript-only can help you. It's only send a request to a server, e.g. http://bot.whatismyipaddress.com/ – Eliseo Jun 01 '18 at 10:12
  • Thanks, But this 3rd party services are returning Ip of ISP. not client pc's IP. I want User's PC's Ip. – Ushma Joshi Jun 01 '18 at 11:57

1 Answers1

2

I Finally found the solution.

var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
for (;!e.atEnd();e.moveNext ())
{
   var p = e.item ();
   if (p.IPAddress!=null ) {
       console.log(p.IPAddress(0)); //User's IP
       break;
   }
}
Ushma Joshi
  • 459
  • 6
  • 19