Jump to content

Active Directory UDF


water
 Share

Recommended Posts

You need to modify _AD_Open.
The example script is only running on a PC that is already joined to a domain. It allows to join ANOTHER PC to a domain.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Correct. Please see the Wiki for details.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 weeks later...

I've noticed an issue when running a 32-bit script on 64-bit with the AD UDF.  

When I run the following, _AD_Open fails with @error = 4 and @extended = -2147023541.  

_AD_Open()
If @error Then Exit 4 +  _FileWriteLog($sLogFilePath, "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ;0x5 Exit Code

For $i = UBound($aFile, 1) - 1 To 1 Step -1
    If Not _AD_ObjectExists($aFile[$i][0] & "$") Then _ArrayDelete($aFile, $i)
Next

_AD_Close()

When I add the DNS Domain, Host Server,  and Configuration parameters, the script runs without issue.  

Global Const $sDNSDomain = "DC=ad,DC=domain,DC=edu"
Global Const $sHostServer = "ad.domain.edu"
Global Const $sConfiguration = "CN=Configuration,DC=ad,DC=domain,DC=edu"

_AD_Open("", "", $sDNSDomain, $sHostServer, $sConfiguration)
If @error Then Exit 4 +  _FileWriteLog($sLogFilePath, "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ;0x5 Exit Code

For $i = UBound($aFile, 1) - 1 To 1 Step -1
    If Not _AD_ObjectExists($aFile[$i][0] & "$") Then _ArrayDelete($aFile, $i)
Next

_AD_Close()

I'm not sure if there is something in the UDF, or if it is just a quirk when running a 32-bit script on 64-bit.  I thought I would report it, in case someone else has this issue.  

 

Adam

 

Link to comment
Share on other sites

Maybe your problem is described here in the wiki (section _AD_Open): https://www.autoitscript.com/wiki/Active_Directory_UDF_-_General#AD_Open

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Reading that part of the wiki is were I got the idea to try entering the add the DNS Domain, Host Server, and Configuration parameters.  Though the section does not mention anything about 32 and 64 bit.  The script worked fine, with the default _AD_Open with no parameters, when run as 32 bit on 32 bit, and 64 bit on 64 bit, but not on 32 bit on 64 bit.  

 

Adam

Link to comment
Share on other sites

I'm running Windows 7 64 bit and never had a problem when using the AD UDF with 32 or 64 bit.
Will test tomorrow to make sure.

Which version of Windows do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

You got me thinking, and a read through my script. I believe that I have found the issue.  It is an issue with the AD UDF and SysWOW64 redirection being disabled.  The script will reproduce the error.  If you switch the _AD_Open call to the one specifying the DNS Domain, Host Server, and Configuration parameters, set to your domain, the script will not error out while redirection is disabled.  

#include <AD.au3>
#include <WinAPIFiles.au3>

;Turn off redirection for a 32-bit script on 64-bit system.
If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)

;Delete PCs from the file that are no longer in AD.
Global Const $sDNSDomain = "DC=ad,DC=domain,DC=edu"
Global Const $sHostServer = "ad.domain.edu"
Global Const $sConfiguration = "CN=Configuration,DC=ad,DC=domain,DC=edu"

_AD_Open("") ;will error.
;~ _AD_Open("", "", $sDNSDomain, $sHostServer, $sConfiguration) ;Will not error with redirection turned off.
If @error Then
    MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
Else
    MsgBox(0, "Active Directory Example Skript", "Function _AD_Open successful.")
EndIf

_AD_Close()

 

Adam

Edited by AdamUL
Link to comment
Share on other sites

Glad the problem could be solved :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Thanks! I have added this problem to the wiki and linked to your post.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hello Water ,

Is it possible to have an Script like ur ADCU 3.2.0.3

but if user have groups inside groups can u add fonction when click on group open list of groups member of . in array of another listview ?

sorry for my english .

i try it alone but i too hard for me :'(

Edited by Tal0nius
Link to comment
Share on other sites

SHould be possible with a "User Function" when you click on a group name in the listview.
But I've never tried before and unfortunately do not have spare time to play with it at the moment.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 weeks later...

Guys - I have used the AD scrips often... and it works great! .. but I just tried it on a Windows 2016 Server and it fails with a simple Create User function?

 

I get a failed message with return code -2147352567

Even the Example Script (Modified slightly below) fails.

Global $sOU , $sUser


_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)


$sOU = "OU=Users,OU=CPT,OU=Locations,OU=AMSOLONE,DC=amsolone,DC=local"
$sUser = "Test"


Global $iValue = _AD_CreateUser($sOU, $sUser, "Test User")
If $iValue = 1 Then
    MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' in OU '" & $sOU & "' successfully created")
ElseIf @error = 1 Then
    MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' already exists")
ElseIf @error = 2 Then
    MsgBox(64, "Active Directory Functions - Example 1", "OU '" & $sOU & "' does not exist")
ElseIf @error = 3 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Value for CN (e.g. Lastname Firstname) is missing")
ElseIf @error = 4 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Value for $sAD_User is missing")
Else
    MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory")
EndIf

_AD_Close()

 

Link to comment
Share on other sites

Will check after my vacation (appr. 1 week)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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, Just some feedback.

It was late last night and I was tired - so blame it on that -  Anyway, ....... I tried to run the program I wrote to add some users to AD, directly on the Windows 2016 server when I received the error listed above ( return code -2147352567 ) Once I joined a PC to the domain, and ran the script from the PC - it worked 100% :-)

Enjoy your leave and your UDF honestly rocks! Best thing ever!

 

Link to comment
Share on other sites

On 20.10.2016 at 4:40 PM, ILoveCoding said:

-2147352567

This stands for "Unexpected error". Might be a permission problem or anything else MS can't give us more details about.

Glad you like the AD UDF :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hello Water,

I use your AD UDF for several Years now and it's really the best custom UDF for AD Manipulation.

Nevertheless I have a small Problem:

I want to read the Value of the AD Attribute "ms-Mcs-AdmPwd" with the Function "_AD_GetObjectAttribute()". Sadly I always get an empty Value, although the Attribute is filled and @error is zero. If I call the Function "_AD_GetObjectProperties()" to get all Attributes, the Values are shown properly.

I did my Tests with the latest Version of AD.au3 (1.4.6.0).

 

Do you have an Idea, how to solve this Problem?

Thanks in advance for your Support.

 

Cheers

Lazegalli

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...