#133618 - 2005-02-10 11:00 PM
LDAP Query
|
Shaun Williams
Lurker
Registered: 2001-12-16
Posts: 2
Loc: Michigan
|
I'm looking to do the following. I basically want to find out what particular OU a machine is in. I don't want the entire DN name, just the OU that it resides in. Any Ideas? I basically looking to do an
IF Object.ou = something ENDIF
|
|
Top
|
|
|
|
#133619 - 2005-02-10 11:29 PM
Re: LDAP Query
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Well, think there are more than a few UDF's that will handle this, search our UDF library for more information, here's one here:
GetComputerOU() - Retrieve OU of computer account
This returns the OU the computer is in, plus all the DC= DC= blah blah crap, but one can modify this UDF to parse/return just what your after ...
By the way, this UDF doesn't even use an LDAP lookup, it looks-up information already on the machine after one logs-in, through ADSystemInfo. ..
|
|
Top
|
|
|
|
#133621 - 2005-02-11 03:49 AM
Re: LDAP Query
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#133623 - 2005-02-11 08:17 PM
Re: LDAP Query
|
Shaun Williams
Lurker
Registered: 2001-12-16
Posts: 2
Loc: Michigan
|
Curious to get you opinions on What I have so far. I'm using a UDF and modifying it to Look for a particular OU, and then go to that Section of the script.
Function GetComputerOU() Redim $TempArray[0] Redim $GetComputerOU $adSys = CreateObject("ADSystemInfo") $TempArray = Split($adSys.ComputerName,",") ; Check if there's a comma in the CN, eg if the user name = "Surname, Name" AD returns "Surname\, Name" If Right($TempArray[0],1) = "\" $Start = 2 Else $Start = 1 EndIf
For $Counter = $Start To UBound($TempArray) If Len($GetComputerOU) = 0 $GetComputerOu = $TempArray[$Counter] + Chr(10) Else $GetComputerOu = $GetComputerOu + "" + $TempArray[$Counter] + Chr(10) EndIf Next Chr(10) ? "--------------------For Each---------------------" + Chr(10)
For Each $Element In $TempArray If $Element = "OU=NA1" ? "Whoo Hoo!" GOTO Brazil ENDIF Next
$adSys = 0
Quit
:Troy ? "Entering TROY Script" GOTO END
:Brazil ? "Entering Brazil" GOTO END
:END quit
EndFunction GetComputerOU()
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1334 anonymous users online.
|
|
|