Finding the OU that was logged into

Networking/Security Forums -> Programming and More

Author: ThePsykoLocation: California PostPosted: Fri Oct 30, 2009 11:52 pm    Post subject: Finding the OU that was logged into
I was troubleshooting an issue that I traced back to the OU.. while troubleshooting I threw together the following .vbs script to tell what OU the computer was in.. But then I started thinking - what if I didn't care what OU the system was in at the time, but what OU they actually logged into (i.e. which group policy was assigned)... if you run the following, move the computer to a new OU, then run it again, what is returned is the current OU that the system is actually in.

Option Explicit
On Error Resume Next

Dim objSysinfo, objUser

Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.ComputerName)
'Set objUser = GetObject("LDAP://" & objSysInfo.UserName)

wscript.echo objUser.AdsPath

Granted, one will likely never have a need for such a script (after all, how often do you really change your system OUs ) but my curiosity has gotten the better of me so I'm curious if there is a way (similar to getting the logon server only for the OU)

Networking/Security Forums -> Programming and More

output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group