Jump to content

Active Directory searching, advice ?


test123

Recommended Posts

Hello my first post :)

I`m not a PC pro so my question my sound stupid but i`ll give it a try.

Is there a way in AD to find out which user is logged to which computer?

For example i have a users ID/logon name and want to find out on wich PC he is logged on?

And is there a way to see the current IP address of a PC searched through AD,

because now to find out the ip i have to ping the PC ( >ping PCNAME )

I tried some combination of "dsquery" and "dsget" but witch no success.

Thx in advance for any replies :)

Link to comment
Share on other sites


IF you are an admin you can just use PSLOGGEDON from SYSINTERNALS (now owned by microsoft)

the below post is a VBSCRIPT that should call PSLOGGEDON.EXE (in your script directory)

you can call it whoislog.vbs

the second part is the OU.TXT for inputing the OUs you want to check against.

(save the text portions without the **** area in two seperate files inside C:\scripts with a copy of pssloggedon.exe)

at a command prompt

C:\scripts >

type then "CSCRIPT whoislog.vbs" sans quotes

Edited by eXtermia
Link to comment
Share on other sites

**********************************************************************************

whoislog.vbs

**********************************************************************************

On Error Resume Next

Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20

OutputFile="c:\scripts\whoisloggedon.txt"

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oFile = oFSO.CreateTextFile(OutputFile, True)

InputFile="c:\scripts\OU.txt"

Set ifile = iFSO.OpenTextFile(inputfile)

Do until ifile.AtEndOfLine

strComputerContainer = ifile.ReadLine

Set objContainer = GetObject("LDAP://" & strComputerContainer)

objContainer.Filter = Array("Computer")

'Set StdOut = WScript.StdOut

Set objShell = CreateObject("WScript.Shell")

Dim strAdminResults

Dim strGuestResults

on error resume next

For Each objComputer In objContainer

strComputer = Split(objComputer.Name, "=")(1)

oFile.WriteLine now()

oFile.WriteLine(" ")

oFile.WriteLine("Computer: " & strComputer)

oFile.WriteLine("---------------------------------------------------")

Set objScriptExec = objShell.Exec("psloggedon" & " \\" & strComputer)

strLoggedOnResults = LCase(objScriptExec.StdOut.ReadAll)

oFile.WriteLine(strLoggedOnResults )

Next

loop

MsgBox "Processing Done "

Function WMIDateStringToDate(dtmDate)

WScript.Echo dtm:

WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _

Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _

& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))

End Function

**********************************************************************************

OU.TXT Modify the the text below to reflect your AD structure the DC site is your FQDN split out

and the ou side is your tree backwards order _MYSITE being the root

**********************************************************************************

ou=Equipment-Laptop,ou=BLDG1,ou=HQ,ou=US,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org

ou=Equipment-PC,ou=BLDG2,ou=FINANCE,ou=ITALY,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org

ou=Equipment-Servers,ou=BLDG1,ou=PROD,ou=GERMANY,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org

Edited by eXtermia
Link to comment
Share on other sites

this is kinda silly and mildly not what you are looking for.. But for my network, when I want to know who is logged into what computer. I open up symantec system center from Norton Corporate. It tells me who is logged on to what computer from the main interface.

But ofcourse this is only if you have symantec corporate managed clients installed on your network.

Link to comment
Share on other sites

this is kinda silly and mildly not what you are looking for.. But for my network, when I want to know who is logged into what computer. I open up symantec system center from Norton Corporate. It tells me who is logged on to what computer from the main interface.

But ofcourse this is only if you have symantec corporate managed clients installed on your network.

I sometimes use this way, too. It works great.

In our logon scripts, we write the user name,full name,date, time, etc. to a file called 'machinename' and the log off scripts removes this file. We use grep, findstr, etc to search these files for a user's logon name.

psloggedon.exe is also easy to use.

-John

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...