gdalinis
(Fresh Scripter)
2009-10-26 06:05 PM
Query Computer OU

Looking for a script to query what OU a computer is part of. Basically, want to write a script that says if a user is logging into a computer that belongs to the 'lab' OU, they will get blah blah blah. Is this possible?

Thanks!


Glenn BarnasAdministrator
(KiX Supporter)
2009-10-26 06:37 PM
Re: Query Computer OU

GetObjectOU() will do this - it's available from the Resources / Kix Function Library page on my web site.

It can return the DN string for a User or Computer. You can then do an InStr() to determine if the desired OU is in the DN string.

Glenn


AllenAdministrator
(KiX Supporter)
2009-10-26 06:48 PM
Re: Query Computer OU

This is one too: GetUserDN() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=188576#Post188576


There are a couple of different variations... look here: UDF Forum - http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1


Richard H.Administrator
(KiX Supporter)
2009-10-27 08:43 AM
Re: Query Computer OU

Or just rip it straight out of ADSystemInfo.
 Code:
Break ON

$objSysInfo = CreateObject("ADSystemInfo") 
$strComputerDN = $objSysInfo.computerName 
$strUserDN = $objSysInfo.userName 

$strUserOU=Split($strUserDN,"OU=")
$strUserOU[0]=""
$strUserOU=Join($strUserOU,"OU=")

$strComputerOU=Split($strComputerDN,"OU=")
$strComputerOU[0]=""
$strComputerOU=Join($strComputerOU,"OU=")


"Information from ADSystemInfo"+@CRLF
"-----------------------------"+@CRLF
"           User DN: "+$strUserDN+@CRLF
"    User container: "+$strUserOU+@CRLF
"       Computer DN: "+$strComputerDN+@CRLF
"Computer container: "+$strComputerOU+@CRLF
@CRLF

Exit 0


gdalinis
(Fresh Scripter)
2009-10-28 09:13 PM
Re: Query Computer OU

Hey all, didn't realize this thread got moved. Just saw the responses. Give me a day to reply back so I can play around with the responses I got. Thanks all.