Deletes the specified object including all child objects of this object.
#Include <AD.au3>
_AD_DeleteSubtree($sObject[, $iFlag = 0])
Parameters
| $sObject | Object (user, group, computer, OU etc.) to delete (FQDN or sAMAccountName) |
| $iFlag | [optional] Specifies how to process child objects. Can be: 0 - Deletes $sObject, all child containers and all leaf objects (default) 1 - Only deletes leaf objects. $sObject and all child containers remain active. Means: The subtree will be cleared. 2 - Deletes child leaf and container objects. Means: The subtree will be deleted, only $sObject remains. |
Return Value
Success: 1
Remarks
Leaf: An object without child objects
Related
_AD_RenameObject, _AD_MoveObject, _AD_DeleteObject
Example
#include <AD.au3>
; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
Global $sObject = InputBox("Active Directory Example Skript - _AD_DeleteSubtree", "Please specify the object (OU) to be deleted:", default, "", 400, 130)
If @error Then Exit
; Delete Subtree
Global $sReturn = _AD_DeleteSubtree($sObject)
If @error Then
Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_DeleteSubtree encountered a problem. @error = " & @error & ", @extended = " & @extended & ", return value = " & $sReturn)
Else
MsgBox(16, "Active Directory Example Skript", "Function _AD_DeleteSubtree deleted " & $sObject & " and all contained OUs and all leaf objects")
EndIf
; Close Connection to the Active Directory
_AD_Close()
Exit