Jump to content

Active Directory UDF


water
 Share

Recommended Posts

If you run it as 32 bit do you still get the wrong results?

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

64 bit

But True return even in 32bit.

Compiled in 3.3.8.1.

My fix:

...
If $aAD_ObjectProperties[$iCount3][0]='objectGUID' Then
$aAD_ObjectProperties[$iCount3][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy)) ; GUID
...
Link to comment
Share on other sites

Hi Water

I seem to have an issue with the below code only after I compile with Obfuscator.

If I compile using the standard compile script to .exe (without Obfuscator) its works fine.

When I remove the computer from AD I get the both msgboxes:

Unable to update description as Computer does not exist in AD!

Unable to move as Computer does not exist in AD!

This what I expect to see, however after I compile with Obfuscator (Ctrl+F7)

The msgboxes I get are different:

Unable to move as Computer is already in that OU!

Computer is already in Active Directory!"

Any ideas?

; Change attribute
$iValue = _AD_ModifyAttribute($ssComputer & "$", "description", $sDescription)
If $iValue = 1 Then
ProgressOn("Please Wait...", "Updating Computer Description in AD.", "Updating...")
For $i = 0 To 100
ProgressSet($i)
Sleep(5)
Next
ProgressSet(100, "Done!")
Sleep(3000)
ProgressOff()
ElseIf @error = 1 Then
MsgBox(64, "Active Directory Error", "Unable to update description as Computer does not exist in AD!")
Else
MsgBox(64, "Active Directory Error", "Computer is already in Active Directory!")
EndIf
; Move object
$iValue = _AD_MoveObject($sOU, $sObject)
If $iValue = 1 Then
ProgressOn("Please Wait...", "Moving Computer to the requested OU.", "Moving...")
For $i = 0 To 100
ProgressSet($i)
Sleep(5)
Next
Local $rc = _RunDos("Gpupdate /force")
ProgressSet(100, "Move Complete!")
Sleep(3000)
ProgressOff()
ElseIf @error = 1 Then
MsgBox(0, "", "")
ElseIf @error = 2 Then
MsgBox(64, "Active Directory Error", "Unable to move as Computer does not exist in AD!")
Else
MsgBox(64, "Active Directory Error", "Unable to move as Computer is already in that OU!")
EndIf
_AD_Close()
GUIDelete($hMain)
Edited by Iceman682
Link to comment
Share on other sites

But True return even in 32bit.

Compiled in 3.3.8.1.

My fix:

If $aAD_ObjectProperties[$iCount3][0]='objectGUID' Then
$aAD_ObjectProperties[$iCount3][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy)) ; GUID

Will be the best solution for the moment. I got the code for SID and GUID from another user but can't find the post where I took it from. Unfortunately I'm no specialist in this area.

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 iceman682,

can you add the values of @error and @extended to your MsgBox?

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 have an AD at home to play with?

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

Sorry it took so long for me to respond.

When running 32 bit, _AD_Open() returns:

@error = 2

@extended = -2147221164

When running 64 bit, _AD_Open() returns:

@error = 0

@extended = 0

Link to comment
Share on other sites

@error = 2 means that the ADODB.Connection couldn't be created.

I fear that on a 64 bit system you can't compile for 32 bit. A 32 bit program can't call a 64 bit DLL.

Looks like you need a 64 bit and a32 bit version of your script.

I'm not very familiar with this things so I could be wrong.

To test you could replace the first 4 lines of _AD_Open with this lines:

; Activate the COM error handler for older AutoIt versions
If $__iAD_Debug = 0 And Number(StringReplace(@AutoItVersion, ".", "")) < 3392 Then _AD_ErrorNotify(2)
$__oAD_Connection = ObjCreate("ADODB.Connection") ; Creates a COM object to AD
If @error Or Not IsObj($__oAD_Connection) Then Return SetError(2, @error, 0)
Edited by water

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

Looks like you need a 64 bit and a32 bit version of your script.

That is what I was afraid of. I guess I will have to make both versions. Maybe make the 32-bit version kick off the 64-bit version.

Thanks for the help.

Link to comment
Share on other sites

MSDN descibes it here.

Maybe you could create a small starter script. It tests the "bitness" and then starts the correct exe.

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

@willichan

Very strange. I just tested with Windows 7 64 bit and this script works fine when compiled as 32 or 64 bit with Autoit 3.3.8.1 or 3.3.9.4.

What's different on your system?

#AutoIt3Wrapper_UseX64=n
#include <AD.au3>

_AD_ErrorNotify(2)
_AD_Open()
If @error Then MsgBox(0,"","Error: in_AD_Open: " & @error & "-" & @extended)
$aResult = _AD_GetobjectProperties(@username)
If @error = 0 Then
    _Arraydisplay($aresult)
Else
    MsgBox(0,"","Error: in_AD_GetobjectProperties: " & @error & "-" & @extended)
EndIf
_AD_Close()
Edited by water

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

Results as follows:

Using ScTE4 Autoit 3 and AD.au3 1.2.0.0

Compiled without Obsfuscator

When Computer is not is AD:

Updating Description in AD= error 1 @extended 0

Moving Computer in AD = error 2 @extended 0

Compiled with Obsfuscator

When Computer is not is AD:

Updating Description in AD = error 0 @extended 0

Moving Computer in AD = error 0 @extended 0

Same results with AD 1.3.0.0

Link to comment
Share on other sites

Did I ask you which version of AutoIt you use?

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.2.0 is the version of the SciTE editor. What do you get when you run

MsgBox(0,"", @AutoItVersion)

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

Could you run this small reproducer both obfuscated and non obfuscated?

#include <AD.au3>
_AD_ErrorNotify(2)
_AD_Open()
$sAD_Object = "Computername" & "$"
Global $iResult = _AD_ObjectExists($sAD_Object)
MsgBox(0, "", "Object Exists:" & @CRLF & "Return value: " & $iResult & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended)
_AD_Close()

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

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...