Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Remote users IP

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
I am createing a vbs file to grab user info on logon.

I currently have
Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUser = ""
While strUser = ""
strUser = WSHNetwork.UserName
wend

I need to be able to log the IP of the person who logs in, how can I do this?

Also how can I write this to a file?

Thanks
 
To retrieve the IP address you may grab the output of the
Code:
 ipconfig
command.
To write to a file you can play with the
Code:
 FileSystemObject
(fso).
Feel free to do keyword searchs in this forum, as this topic has been many times discuted.

Hope This Help
PH.
 
You could also use WMI if the workstation supports it (2k/xp/2k3). If it doesn't, you could push WMI to it. I'd recommend that, because WMI is nice to have available :)
-------------------------------------------------------
Set WMI = GetObject("winmgmts:" & "!\\.\root\cimv2")
Set NICs = WMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each NIC in NICs
if not isnull(NIC.IPAddress) then
for x=lbound(NIC.IPAddress) to ubound(NIC.IPAddress)
msgbox NIC.Description & " IP Address " & x & ": " & NIC.IPAddress(x)
next
end if
next

Set NICs = Nothing: Set WMI = Nothing
 
Oh yea, if you want to snag the IP info of a remote system, that is to say run it from your box and get the IPs of another, where it has:

Set WMI = GetObject("winmgmts:" & "!\\.\root\cimv2")

Replace the . in !\\.\ with the name of the PC to scan.
 
if you were using ASP, could you not just use a servervariable? the code would look like this

dim variable
variable= request.serverVariable("remote_addr")

then you can do whatever you want to with the variable.

p.s. you might want to check up on servervariables - because I tried to use on before only to find that the variable name had changed. Search on google or ask jeeves
 
Well what I am trying to do is grab the IP of a remote box when it logs into mine using VBS, I know I can grab it using ASP but I cannot use that is a VBS file.

For instance if you look at security logs on a 2000 or 2003 server you will see it shows remote user connected then time date and IP address.

I just want to grab a remote IP of a box without any user intervention.

Thanks
Nick
 
Set WshSock = Wscript.CreateObject("MSWinsock.Winsock")
strIP = WshSock.LocalIP
Set WshSock = Nothing
 
This does not work

Maybe I need to be a littel clearer.

I log into a windows 2003 server using terminal Services and when I do I run a logon script which is a VBS file that grabs my user name I logged in as and sends it using Cdosys to an email address, I then then know who logs into my server.

What I want to do is not only log my username but I want to log what IP I logged in FROM (Remote IP) I need to do this in VBC not ASP.

I know this is possible since when I look at the security logs I can see the Remote Source Ip address.

Once again I do not want to know the IP's on the server I need to know the IP of the user that logged in.


Thanks

 
i suggest something from the terminal services resource kit then. if not does the eventlog have all teh information you require? if so then read the eventlog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top