PDA

View Full Version : Getting the IP of the remote client from a logon script? (W2K)



grendello
12-18-2005, 02:26 PM
Hello,
I've been looking for this information for quite a while and I cannot determine how can I get the IP address of a remote machine from which a user logged in to a Windows 2003 Server terminal service. I need that information in order to map some generic shares from the machine the user is logging in from to make them available for the user during their terminal session.
The script is to be used in a university lab, that's why I need to determine the IP address of the remote machine dynamically in the logon script.
Is it possible to retrieve that IP from a script at all?

thanks in advance,

marek

Brf
12-19-2005, 07:18 AM
I would think that a terminal user, running a script on a server, would get the IP of server, not the client....

motoflop
12-21-2005, 10:26 AM
So you want to create script, which user can run locally after starting terminal server connection to some server in order to map some shares from that server? With netstat command you can see current connections. Terminal server sessions are using tcp/ip port 3389. Your script should run netstat and capture output. Then it should locate line containg port 3389 and pick ip address from that line. Output of netstat is like:

c:\>netstat -n

Active Connections

Proto Local Address Foreign Address State
TCP 10.0.0.1:3747 72.14.207.99:3389 ESTABLISHED

In this example address of remote terminal server is "72.14.207.99".