SystemTools ToolBoard
  How Do I ... ?
  Get and IP Address from a Username

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Get and IP Address from a Username
Dbunt
Junior Member
posted 09-10-2006 05:50 PM     Click Here to See the Profile for Dbunt     Edit/Delete Message   Reply w/Quote
Hi all,

Apolgies if this has already been asked...

Is there anyway, using a person's AD username, get the IP address they have been assigned and/or workstation name of the computer they are on...

Regards

Dbunt

IP: Logged

cmccullough
Administrator
posted 09-11-2006 10:06 AM     Click Here to See the Profile for cmccullough     Edit/Delete Message   Reply w/Quote
You typically have to get this from the computer side, rather that from the user. You can select your computers in Hyena's right window, then right-click and choose View Logged on Users. When that is finished you can use the Copy to Clipboard option and paste into Excel. Then refer to that spreadsheet whenever you need to find a user.

IP: Logged

Dbunt
Junior Member
posted 09-11-2006 05:26 PM     Click Here to See the Profile for Dbunt     Edit/Delete Message   Reply w/Quote
Hi, thanks for the reply.

I do know about the option to see who is on a specific computer - the reason for my question is I am in a business where user's logon to different computers, and we use VNC to remote control them for troubleshooting, a lot of the time the user does not know their computer name and/or ip address.

Regards,

Dbunt

IP: Logged

Trammel
Member
posted 09-13-2006 12:28 AM     Click Here to See the Profile for Trammel     Edit/Delete Message   Reply w/Quote
Actualy I have a tool that can do what your asking. It is not 100% solid as net send's can fail for many reasons. First thing you could ask the user is to type %computername% in the Run line and ask them what the popup says. It should say something like "Windows can not find (users machine name). This will give you the name of their computer without having to walk a user through allot of right clicks and such.

Please note that I used this tool from a share point on the net work. My command was called "Find Users Computer" The command was \\servername\Scripts\HyenaTools\Scripts\whereisuser.bat %E%

Batch file:
@ECHO OFF
ECHO Trying to find the computer that the user is logged into...

NET SEND %1 "HelpDesk is looking for your computer -- Just Click OK"
NBTSTAT -c | find /i "%1" > usr.txt
FOR /f "tokens=4 delims= " %%i in (usr.txt) do set machineip=%%i
PING -a -n 1 %machineip% > ip.txt
TYPE ip.txt | find /i "Pinging" > ip1.txt
FOR /f "tokens=2 delims= " %%i in (ip1.txt) do set machinename=%%i

ECHO Username = %1
ECHO IP Address = %machineip%
ECHO Computer = %machinename%
ECHO.

PAUSE

I have a couple of other find user files that also work. I will past the code for each file in italics.

finduser.js
// Tommy Strömgren, 2005-06-21 (tommy.stromgren (at) scania.com)

var oShell = new ActiveXObject("WScript.Shell");
var oArgs = WScript.Arguments;
var User = oArgs(0).toUpperCase().replace(/\/d/g, "");
// Avoids accidental usage of the switch /d
//(/d = send to entire domain)

oShell.Exec("net send "+ oArgs(0) + " \"\"");

WScript.Sleep(500); // It takes some time before the NetBIOS cache displays the name
var Cache = oShell.Exec("nbtstat -c").StdOut.ReadAll().replace(/\r/g,"");

var UserLine = Cache.slice( Cache.indexOf( User ) );
var UserLine = UserLine.slice( 0 , UserLine.indexOf("\n") );

var UserIP = UserLine.slice(37 , 52).replace(/\s/g,"");

var RemoteCache = oShell.Exec( "nbtstat -a " + UserIP ).StdOut.ReadAll().replace(/\r/g,"");

WScript.Echo(
"Empty \"net send\" message sent to: " + User +"\r\n" +
"Local NetBIOS cache entry:\r\n"+UserLine +"\r\n\r\n" +
"Registered NetBIOS Names on "+ UserIP +":"+ RemoteCache
);


finduser.vbs
'************* Begin Script Here *********
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
'
' NAME: FindUser.vbs
'
' AUTHOR: Joel Thoreson , USAALS / AEPCO
' DATE : 5/6/2003
'
' COMMENT: Finds a user on the domain.
'
'==========================================================================

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
Dim WshNetwork : Set WshNetwork = WScript.CreateObject("WScript.Network")
Dim objArgs : Set objArgs = WScript.Arguments ' create object with collection
Dim fso : Set fso = WScript.CreateObject("Scripting.FilesystemObject")
Const ForReading=1, ForWriting=2


If objArgs.Count >= 1 Then
strUserName = objArgs(0) 'assign the passed user name to a variable
Else 'quit the script, no variable given, or too many variables passed
strUserName = InputBox("Enter the loggon of the individual you wish to query",,WshNetwork.UserName)
If strUserName = "" Then WScript.Quit
End If

If IsNull(strUserName) OR strUserName = "" Then WScript.Quit

OutputFilePath = "c:\ip1.txt"

' Flush the cache
WshShell.Run "cmd /c nbtstat.exe -R", 2, False
WScript.Sleep 1000
' Send a message to the user
WshShell.Run "cmd /c net send " & strUserName & " User locator message.", 2, True
WScript.Sleep 1000
' check the local machines cache, looking for UNIQUE
WshShell.Run "cmd /c nbtstat.exe -c | find ""UNIQUE"" > " & OutputFilePath, 2, True
WScript.Sleep 1000

On Error Resume Next

Dim objFile : Set objFile = fso.OpenTextFile(OutputFilePath, ForReading)
Dim strIPAddress : strIPAddress = Trim(Mid(objFile.ReadLine,42,15)) 'read the line

' Nobody home
If Err.Number <> 0 Then
WshShell.Popup "User '" & UCASE(strUserName) & "' is most likely not logged on anywhere.", 8, "User not found"
objFile.Close
fso.DeleteFile(OutputFilePath)
WScript.Quit
End If
objFile.Close

WshShell.Run ("cmd /c nbtstat.exe -A " & strIPAddress & " > " & OutputFilePath)
WScript.Sleep 1000

Set objFile = fso.OpenTextFile(OutputFilePath, ForReading)

Do While objFile.AtEndOfStream <> True
aline=Trim(objFile.Readline) 'read a line
SearchString = "<20>" '20 says file sharing is installed and enabled. See Below!!
MyPos = Instr(1, aline, SearchString, 1) ' A textual comparison starting at
If MyPos <> 0 Then
strComputerName = Trim(Left(aline, (MyPos-1)))
MsgBox "Machine Name: " & strComputerName
End If
Loop

objFile.Close
Set objFile = Nothing
fso.DeleteFile(OutputFilePath)

' when running nbtstat, these are the codes
'00 Base computer name and Workgroups
'01 Master Browser
'03 Message Alert service (name of logged in user)
'20 Resource Sharing `server service` name
'1B Domain master-browser name
'1C Domain controller name
'1E Domain/workgroup master browser election announcement
'**************** End Script Here *********

[This message has been edited by Trammel (edited 09-13-2006).]

IP: Logged

All times are ET (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | SystemTools Home Page

Copyright � 2001 - 2006 SystemTools Software, Inc.

Powered by Infopop www.infopop.com © 2000
Ultimate Bulletin Board 5.46