0

I have Windows 2008 R2 server with enabled IP virtualization for Terminal services. I need to know in my program which virtual IP was assigned to session where I run my program.

Now when I get IP address:

        String strHostName = Dns.GetHostName();
       IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
        IPAddress[] addr = ipEntry.AddressList;

I have only IP of a server not virtual IP assigned to session.

How can I get (using c#) this virtual IP?

Best regards, Piotr

user1598155
  • 51
  • 1
  • 3

2 Answers2

0

you may try this

System.Net.IPAddress[] IpAddresses = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());

for (int i = 0; i < IpAddresses.Length; i++)
{
   Console.WriteLine("IP Address {0}: {1} ", i, IpAddresses[i].ToString());
}
skjcyber
  • 5,759
  • 12
  • 40
  • 60
-1

Use WTSQuerySessionInformation

Garis M Suero
  • 7,974
  • 7
  • 45
  • 68