Hi Guys/Gals,
I'm using the AD UDF to interogate our AD (the computers section, which we have under an OU of managed), what I'm trying to do (and failing horribly) is recurse through the sub OU's and place them inside a treeview container.
e.g Access |
|-Teachers
|- Students
|-Office
but I can't get it to go past the first sub OU, and it's creating duplicates...
my code is below
AutoIt
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ProgressConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <AD.au3> $ADToolbox = GUICreate("ADToolbox", 1245, 789, 192, 124) $Root = GUICtrlCreateTreeView(8, 8, 241, 769, BitOR($GUI_SS_DEFAULT_TREEVIEW,$WS_BORDER)) $Itemspane = GUICtrlCreateListView("", 256, 8, 801, 681) $taskprog = GUICtrlCreateProgress(256, 696, 801, 25, BitOR($PBS_SMOOTH,$PBS_MARQUEE,$WS_BORDER)) GUISetState(@SW_SHOW) _AD_Open() Global $aOUs = _AD_GetAllOUs("OU=Computers,OU=Managed,DC=SCHOOL,DC=LOCAL", "", 0) If @error > 0 Then MsgBox(48, "Active Directory Functions", "No OUs could be found") Else $iCount = 2 Do $sOU = "ou=" & StringReplace($aOUs[$iCount - 1][0], "\", ",ou=") & "," & $sAD_DNSDomain $trunk = stringsplit($sOU, ",") if $trunk[0] > 4 Then $leafcount = 0 $branchno = 0 do if $branchno = 0 then if $trunk[5] <> "DC=Local" and $trunk[5] <> "DC=SCHOOL" then $branch = GUICtrlCreateTreeViewItem($trunk[5], $root) $branchno = 1 $leafcount = $leafcount + 1 else $leafcount = $leafcount + 1 EndIf Else $count = 0 $leafname = 0 do if $leafname = 0 Then if $trunk[6] <> "DC=Local" and $trunk[6] <> "DC=SCHOOL" then $leaf = GUICtrlCreateTreeViewItem($trunk[6], $Branch) $leafname = 1 $count = $count + 1 else $count = $count + 1 $leafname = 0 EndIf endif until $count = $trunk[0] $leafname=0 $branchno = 0 $count = 0 EndIf until $leafcount = $trunk[0] $leafcount = 0 $branchno = 0 EndIf $iCount=$iCount+1 until $iCount = $aOUs[0][0] EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
thanks in advance
RichE