Page 1 of 1 1
Topic Options
#208427 - 2014-01-29 03:53 PM Getting OU information for a group of servers
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I've had a small group of Windows 2008 servers that I administer that are part of a larger domain in which I am not a domain admin. Out of curiosity, I was just trying to see if my servers were in a seperate OU or not. So, used Arend's ListOUObject function to try and list, but got nothing. Do you think it is likely they have restricted access to this information for domain admins, or is there a problem with my code?
 Code:
Break On
$=SetOption("Explicit","On")
$=SetOption("WrapAtEOL","On")
Dim $strADsPath, $strBeg, $strLDAP, $arrItems, $strItem
$strADsPath = GetObject("LDAP://rootDSE").Get("defaultNamingContext")
Include "functions.kix"
$strBeg = "LDAP://"
$strLDAP = $strBeg + "OU=Computers," + $strADsPath
$arrItems = ListOUObjects($strLDAP,"computer")
For Each $strItem In $arrItems
   ? $strItem
Next
$strLDAP = $strBeg + $strADsPath
$arrItems = ListOUObjects($strLDAP,"organizationalUnit")
For Each $strItem In $arrItems
   ? $strItem
Next


Edited by BradV (2014-01-29 05:40 PM)
Edit Reason: Fixed typo

Top
#208433 - 2014-01-29 04:47 PM Re: Getting OU information for a group of servers [Re: BradV]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Well maybe this typo: "OU=Compuers," ? \:D
Top
#208434 - 2014-01-29 04:54 PM Re: Getting OU information for a group of servers [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Btw, to make sure you have access to browse the LDAP, use Softerra's LDAP Browser it's free and it allows you to see the structure, then you have enough permissions to do so.
Top
#208435 - 2014-01-29 05:40 PM Re: Getting OU information for a group of servers [Re: Arend_]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Hi Arend, no that was simply a typo. I have to type everything in manually. I'll have to check our central software library to see if there are any FOS LDAP browsers. Thanks! \:\)
Top
#208436 - 2014-01-29 05:54 PM Re: Getting OU information for a group of servers [Re: BradV]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Your code works fine in my domain though.
Top
#208437 - 2014-01-29 06:02 PM Re: Getting OU information for a group of servers [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Or, if you have kixforms classic installed, use this magnificent free ldap browser script
Top
#208511 - 2014-02-05 04:53 PM Re: Getting OU information for a group of servers [Re: BradV]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Enumerating the default computers container may not show you what you want to know if your computers are not located there. I would suggest using the TranslateName() UDF to explicitly lookup your server names and display the distinguishedName or canonical name to see where they are located in the OU structure.

 Code:
$NameArray = TranslateName (1, @LDomain, 3, @Domain + "\" + @wksta + "$", "1,2")
if @error=0
	$WkstaDN            = $NameArray[1]
	$WkstaCanonicalname = $NameArray[2]
endif


you can get the UDF in the UDF library.


Edited by Howard Bullock (2014-02-05 04:58 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#208515 - 2014-02-05 06:31 PM Re: Getting OU information for a group of servers [Re: Howard Bullock]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Thanks! It turns out they had disabled the servers in the OU since I didn't have the SP1 installed. Part of the problem was that the people responsible for downloading the service pack couldn't understand that Windows 2008 R2 is different than Windows 2008. I basically had to yell at them to get the correct version. \:\)
However, after getting it, there just wasn't enough free space on the servers to install. All of the developers have since moved off of these virtual servers to some different Linux based virtual servers. I just turned off the last one yesterday. I was hoping to be complete in my ticket telling them to remove our workstations from the domain and remove the associated security groups. They'll figure it out. \:\)

Thanks for all of the suggestions!

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 793 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.058 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org