VMware

This Question is Answered

1 "helpful" answer available (6 pts)
5 Replies Last post: Mar 27, 2009 8:25 AM by wbarnes  

Getting the View client's IP address posted: Mar 23, 2009 4:06 PM

Click to view guyrleech's profile Virtuoso 1,810 posts since
Mar 6, 2006

I have some code that uses the well established WTSQuerySessionInformation() API call (http://msdn.microsoft.com/en-us/library/aa383838(VS.85).aspx), via the WTSClientAddress argument, to retrieve the IP address of the client that is connected to an RDP session.

When this code is run inside a View session (on XP SP3), it always returns 127.0.0.1 rather than the IP address of the client connecting to the View session. If I disconnect the View session and reconnect as the same user via an RDP console session then the client IP address is correctly returned. Using the WTSClientName argument to return the client name always returns the correct client name, regardless of whether the session is connected through RDP or the View client.

Anyone got any ideas how I retrieve the client IP address please? Probably should be posted to a developer community but I can't really find a relevant one.


Re: Getting the View client's IP address

1. Mar 23, 2009 11:42 PM in response to: guyrleech
Click to view rrdharan's profile Expert 462 posts since
Dec 16, 2004
This is happening because of the View tunnel, because in tunneled mode the RDP control connects to 127.0.0.1 (on the client-side) and the socket connection is then tunneled over to the remote side. The session information is populated with information provided by the RDP client hence the discrepancy.

We intend to address this issue in a future version of VMware View by providing various details about the client as environment variables available from within the RDP session, including the client's true IP address, e.g.:

ViewClient_Broker_DNS_Name=broker.foo.com
ViewClient_Broker_Remote_IP_Address=1.2.3.4
ViewClient_Broker_Tunneled=false
ViewClient_Broker_URL=https://broker.foo.com:443
ViewClient_IP_Address=5.6.7.8
ViewClient_LoggedOn_Domainname=FOO
ViewClient_LoggedOn_Username=user
ViewClient_Machine_Domain=bar
ViewClient_Machine_Name=baz
ViewClient_MAC_Address=00-12-34-56-BE-EF
ViewClient_Type=Windows

Re: Getting the View client's IP address

2. Mar 24, 2009 1:13 AM in response to: guyrleech
Click to view Christoph Dommermuth's profile Expert 553 posts since
Jan 16, 2008
At the moment you could use the %Clientname% env. variable on the virtual desktop. write a script where you ping this variable and you'll get back the IP.

Blog: http://communities.vmware.com/blogs/dommermuth

Re: Getting the View client's IP address

5. Mar 27, 2009 8:25 AM in response to: guyrleech
Click to view wbarnes's profile Lurker 1 posts since
May 25, 2006

I'm looking for this functionality as well.

I can script a fair amount of things if I know where the client is on our network. (closet printer, etc.)

my temporary workaround is to carefully name my thin clients, and use that in my scripts if the IP address comes back as 127.0.0.1

(I'm using WTSManager.shell in my scripts)

here's a snippet of what I'm doing:

if ( ipaddress = "127.0.0.1" ) then
ClientName = WTS.MyClientName
matchClientName = left(ClientName,6)
Select Case matchClientName
Case "XX-F1-": Vlan = 189
Case "XX-F2-": Vlan = 182
Case "XX-F3-": Vlan = 186
Case "XX-F4-": Vlan = 184
End Select

somethign like that.


VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities