Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Recursive Searching dsGetChildPath vs dsFindPath
That being said, here is an example of performing a recursive search with dsGetChildPath:
; Initialize some variables. sAllClasses = "" ; Our results - must be initialize. nDepth = 0 ; Always set to 0 at the start. sPath = "LDAP://myserver" ; Our starting point in the object tree. ; This does all the work. gosub GetClasses ; Display the results. message("List of classes", sAllClasses ) nCount = ItemCount(sAllClasses, @Tab) message( "Number of classes", nCount) exit ;******************************************************************** ;* Name: GetClasses ;* ;* Purpose: Traverses an Active Directory object hierarchy. ;* ;********************************************************************/ :GetClasses if strlen(sPath) == 0 then return ; This should be an error. ; Add this objects class name. gosub AddObjectsClass ; Get child paths. sChildPaths%nDepth% = dsGetChldPath(sPath, "") nChildCount%nDepth% = ItemCount(sChildPaths%nDepth%, @Tab) ; Check each child. while nChildCount%nDepth% > 0 ; Get the next sibling. sPath = ItemExtract(1,sChildPaths%nDepth%, @Tab) sChildPaths%nDepth% = ItemRemove(1, sChildPaths%nDepth%, @Tab) ; Check the children of this sibling. nDepth = nDepth + 1 gosub GetClasses ; Recurse to the next level. nDepth = nDepth - 1 nChildCount%nDepth% = nChildCount%nDepth% - 1 endwhile return ; GetClasses ;******************************************************************** ;* Name: AddObjectsClass ;* ;* Purpose: Adds an AD object's classes to a list of class names. ;* ;********************************************************************/ :AddObjectsClass ; Get the class names sClassList = dsGetProperty( sPath, "objectClass") ; Objects can have more than one class. nNameCount = Itemcount(sClassList, @TAB) for i=1 to nNameCount sClass = ItemExtract(i, sClassList, @Tab) ; Check if class name is already in list. if ItemLocate (sClass, sAllClasses, @TAB) == 0 ; Add to the class list. sAllClasses = ItemInsert(sClass, -1, sAllClasses, @TAB) endif next return ; AddObjectsClass
Article ID: W15047
File Created: 2002:10:08:10:34:24
Last Updated: 2002:10:08:10:34:24