Jump to content

Active Directory UDF (II)


water
 Share

Recommended Posts

On 4.2.2018 at 7:17 PM, DFWITGuy said:

ETA - Solved my own problem.  User error!

Glad the problem could be resolved :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Here is the beta version of function _AD_DeleteSubTree:

; #FUNCTION# ====================================================================================================================
; Name...........: _AD_DeleteSubtree
; Description ...: Deletes the specified object including all child objects of this object.
; Syntax.........: _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 values .: Success - 1
;                  Failure - The distinguishedName of the object raising the error, sets @error to:
;                  |1 - $sObject does not exist
;                  |2 - Error returned by DeleteObject method for an object (Missing permission etc.). @extended holds the COM error code.
;                  |3 - Error returned by DeleteObject method for an OU (Missing permission etc.). @extended holds the COM error code.
; Author ........: water
; Modified.......: The function only handles OUs as container objects at the moment.
; Remarks .......: Leaf: An object without child objects
;                  Container: An object that can hold child objects (leafs or containers)
; Related .......: _AD_RenameObject, _AD_MoveObject, _AD_DeleteObject
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _AD_DeleteSubtree($sObject, $iFlag = 0, $iRecursion = 0)

    ; Only check the object provided by the user on first call (performance reasons). Values: 0 = first call by user, 1 = recursive call
    If $iRecursion = 0 Then
        If Not _AD_ObjectExists($sObject) Then Return SetError(1, 0, $sObject)
        If StringMid($sObject, 3, 1) <> "=" Then $sObject = _AD_SamAccountNameToFQDN($sObject) ; sAMAccountName provided
    EndIf
    Local $oObject = __AD_ObjGet("LDAP://" & $sAD_HostServer & "/" & $sObject)
    Local $sClass = $oObject.Class
    If $sClass = "organizationalUnit" Then
        For $oChild In $oObject
            _AD_DeleteSubtree($oChild.distinguishedName, $iFlag, $iRecursion + 1)
            If @error Then Return SetError(@error, @extended, $sObject)
        Next
        If $iFlag <> 1 Then
            ; OUs will not get deleted when $iFlag = 1 (clear subtree)
            $oObject.DeleteObject(0)
            If @error Then Return SetError(3, @error, $sObject)
        EndIf
    Else
        ; Objects will always be deleted. Except $sObject when $iFlag = 2
        If Not ($iFlag = 2 And $iRecursion = 0) Then
            $oObject.DeleteObject(0)
            If @error Then Return SetError(2, @error, $sObject)
        EndIf
    EndIf
    Return 1

EndFunc   ;==>_AD_DeleteSubtree

It will be part of the next relase of the AD UDF.
Please test and report bugs in this thread.
Please be aware that this function might lead to unexpected results as I have no AD available to test.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi ,

i'm french so sorry for my bad english .

I'm new in AutoIt . I installed the AD UDF but the calltips doesn't work .

I used the User CallTip Manager from SciTe config tool just like said in Readme.txt . I put my AD.au3 in INclude folder and choose the file in use Calltip Manager . I've added every function found and Saved . The #include <AD.au3> on the beginning of my code is here but calltips and syntax highlighting doesn't work :/

 

Thank you for your answer .

Link to comment
Share on other sites

Hi Water and community,

Greatest of job on what you've done with AD UDF and ADAT.  I attempted to compile ADAT for use in my department. Unfortunately it seems that the 'Process' button functionality doesn't appear to work for any tabs.  It does work at runtime in SciTE, but not as a stand-alone executable.  Any thoughts on what to do/change? 

Link to comment
Share on other sites

Which version of the AD UDF do you use? Which version of AutoIt do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@keiothic
I noticed the same behavior here. Need to check when I find some spare time :ermm:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@Angelhell02,
I tested with SciTE 3.7. and AD UDF 1.4.8.0 and it works as expected. Did you restart SciTE?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

3 hours ago, water said:

@keiothic
I noticed the same behavior here. Need to check when I find some spare time :ermm:

This is caused by Au3Stripper and the useage of "Call" in the script.

Please add the following line at the top of the script and the compiled version should run fine.

#Au3Stripper_Ignore_Funcs=Process_Tab*
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi @Water,

I've updated AutoIt to 3.3.14.4 and AD to 1.4.8.0, and I've got an error while running code that used to work:

It seems an include is missing from AD.au3, as simply running the example code for _AD_Open() results in an error regarding the function _WinAPI_StringFromGUID().

This is the output I get in the console:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\Include\AD.au3" /UserParams    
+>09:03:16 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00001009  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Robert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Robert\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.4)  from:C:\Program Files (x86)\AutoIt3  input:C:\Program Files (x86)\AutoIt3\Include\AD.au3
"C:\Program Files (x86)\AutoIt3\Include\AD.au3"(2235,99) : error: _WinAPI_StringFromGUID(): undefined function.
                        $aObjectProperties[$iPropertyRecord][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy))
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files (x86)\AutoIt3\Include\AD.au3 - 1 error(s), 0 warning(s)
!>09:03:17 AU3Check ended. Press F4 to jump to next error.rc:2
+>09:03:17 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 1.204

By adding

#include <WinAPIConv.au3>

to the top of AD.au3 the sample code runs as it did with 3.3.14.2 and AD 1.4.8.0 (I never tried it with AutoIt 3.3.14.3)

Is there something I'm missing?

Thanks!

Link to comment
Share on other sites

Thanks for the heads up.
Is described on the download page:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Water

I'm trying to populate a TreeView using your _AD_GetOUTreeView with selected OUs.

For example an OU "Students" with child OUs under it "2018", "2019", "2020", "2021", "2022", "2023", etc. where I would pick "2018", "2019", "2020", "2021" to be in the TreeView.

Looping through those 4 OUs will populate the TreeView however when trying to retrieve the currently selected item in the TreeView it always only returns what correctly what was added in the last supplied OU loop. 

This is a copied simplified script that works great, because it does grab all the sub OUs under "Students".

I short, is there a way to pick and choose what child OUs populate a TreeView using   _AD_GetOUTreeView

Thanks

Link to comment
Share on other sites

16 hours ago, lewisg said:

In short, is there a way to pick and choose what child OUs populate a TreeView using   _AD_GetOUTreeView

Not at the moment.
_AD_GetOUTreeView calls _AD_GetAllOUs which returns all OUs. You would need to modify the returned array.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 2 months later...

I just wanted to report a bug I have come across in _AD_RecursiveGetMemberOf:

"C:\Local\au3\Include\AD.au3" (1111) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$aGroups[$iCount1] = $oRecordSet.Fields(0).Value
^ ERROR

The fix I have found for this error is highlighted below:

$oRecordSet.MoveFirst
    $iCount1 = 1
    Local $aTempMemberOf[1]

    ; error fix
    If UBound($aGroups) <= $iCount1 Then Return ""
    ; error fix

    Do
        $aGroups[$iCount1] = $oRecordSet.Fields(0).Value
        If $iDepth > 0 Then
            $aTempMemberOf = _AD_RecursiveGetMemberOf($aGroups[$iCount1], $iDepth - 1, $bListInherited, $bFQDN)

Just posting in case someone else comes across this!

Link to comment
Share on other sites

Thanks a lot for this error report!

Can you please describe the case that causes this error?

  • Is it caused by a COM error? To check this could you please add "_AD_ErrorNotify(1)" at the top of your script and post the result from the SciTE output pane?
  • Is it caused by an empty group?
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...