Jump to content

Recommended Posts

Posted

Hello,

i would like to get some AD information

i get a csv file with the group list to proceed my audit.

i want to generate an csv file with : AD.AU3

groupname;descriptiongroup;user0;user1,user2,user3... etc...

i can give more information if requierd

; #FUNCTION#

==============

; Name...........: _AD_GetObjectAttribute

; Description ...: Returns the specified attribute for the named object.

; Syntax.........: _AD_GetObjectAttribute($sAD_Object, $sAD_Attribute)

SOURCE CODE :

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=AEP\Auditgroup_OK.exe
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AD.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <file.au3>
#include <TreeViewConstants.au3>
#include <GuiListView.au3>

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 365, 147, 192, 114)
$Button1 = GUICtrlCreateButton("fichier", 280, 8, 75, 25)
$Label1 = GUICtrlCreateLabel("--", 8, 48, 172, 17)
$Label2 = GUICtrlCreateLabel("--", 192, 48, 164, 17)
$Label3 = GUICtrlCreateLabel("click scan => ", 196, 112, 75, 25)
$Progress2 = GUICtrlCreateProgress(8, 88, 350, 16)
$Button2 = GUICtrlCreateButton("open", 8, 112, 75, 25)
$Button3 = GUICtrlCreateButton("Scan", 280, 112, 75, 25)
$listgroup = GUICtrlCreateInput(@ScriptDir & '\listgoup.csv', 8, 8, 265, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

Dim $aRecords
Global $GetFolerpath, $ListeTable1, $SUserId, $sPassword, $sAD_DNSDomain, $sAD_HostServer, $sAD_Configuration, $liste
Dim $hListView

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
getfile()
Case $Button3
scan()
EndSwitch
WEnd

Func getfile()

Local $message = "Selectionner un fichier contenant la liste des groupes"
Local $var = FileOpenDialog($message, @ScriptDir & "\", "Grouplist (*.csv)", 1)

If @error Then
MsgBox(4096, "", "No File(s) chosen")
Else
GUICtrlSetData($listgroup, $var)
EndIf
EndFunc ;==>getfile

Func scan()

FileDelete(@ScriptDir & '\audit_groupe.csv')
_AD_Open()
GUICtrlSetData($Label3, 'EN COURS')
Local $groupesamaccount, $countlogline

$tt = 0

$countline = _FileCountLines(@ScriptDir & '\listgoup.csv')
$fopen = FileOpen(@ScriptDir & '\listgoup.csv', 0)

While 1
$groupe = FileReadLine($fopen)
If @error = -1 Then ExitLoop

$tt = $tt + 1
$p2 = ($tt * 100) / ($countline)
GUICtrlSetData($Progress2, $p2)
GUICtrlSetData($Label1, $groupe)

$groupeFQDN = _ad_SamAccountNameToFQDN($groupe)
$result = _AD_GetGroupMembers($groupeFQDN)
;~ _ArrayDisplay($result)

GUICtrlSetData($Label2, $result[0])

$filetemp = FileOpen(@ScriptDir & '\audit_groupe.csv', 1)
Local $description = 'description'
;~ MsgBox(64, '$groupe & $tt & $result[0] ', $groupeFQDN & ' ' & $tt & ' ' & $result[0], 1000)


Local $groupdescription = $sAD_Object($groupeFQDN, 'desctiption')
MsgBox(64, '$groupedescription', $groupdescription, 1000)

If $result[0] = 0 Then
FileWriteLine($filetemp, $groupeFQDN & '; no member')
Else
For $x = 1 To $result[0]

;~ MsgBox(64, '$result[$x] ', $result[$x], 1000)
;~ local $FQDN = $result[$x]
;~ $usertowrite = _AD_FQDNToDisplayname($FQDN)
;~ MsgBox(64,'',$usertowrite,1000)

If $x = 1 Then
FileWriteLine($filetemp, $groupe & ';' & $result[$x])
Else
FileWriteLine($filetemp, ' ' & ';' & $result[$x])
EndIf
Next
EndIf

FileClose($filetemp)
Sleep(500)
WEnd
_AD_Close()
GUICtrlSetData($Label3, 'TERMINE')
EndFunc ;==>scan

ERROR

>Running:(3.3.8.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\DEV\deleteuserlist\AEP\Auditgroup_OK.au3"

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
C:\Program Files (x86)\AutoIt3\Include\AD.au3 (4378) : ==> Variable must be of type "Object".:
Return $__oAD_OpenDS.OpenDSObject($sAD_FQDN, $sAD_UserId, $sAD_Password, $__bAD_BindFlags)
Return $__oAD_OpenDS^ ERROR
->19:07:09 AutoIT3.exe ended.rc:1
>Exit code: 1 Time: 6.205
Posted

There is a typo: desctiption

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

 

Posted

desctiption or description ?

i mean my error is ==> Variable must be of type "Object".:

What does that mean ? i call it with bad arguments or i can't call this argument ?

Posted

It would be interesting to know wich function triggers the error.

Which version of the UDF do you use (can be found in the header lines?)

Can you remove $sAD_DNSDomain, $sAD_HostServer, $sAD_Configuration from your script? They are defined and used in the UDF itself.

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

 

Posted

Local $groupdescription = $sAD_Object($groupeFQDN, 'desctiption')

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Replace line

Local $groupdescription = $sAD_Object($groupeFQDN, 'desctiption')
with
Local $groupdescription = _AD_GetObjectAttribute($groupeFQDN, 'description')

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

 

Posted (edited)

First of all thank you for responding

Water check my AD.AU3 version here

; #INDEX# =======================================================================================================================
; Title .........: Active Directory Function Library
; AutoIt Version : 3.3.9.2 or later (because of _Date_Time_SystemTimeToDateTimeStr and the latest in COM error handling)
; UDF Version ...: 1.3.0.0
; Language ......: English

Desctiption => doesn't exist

anyway

$groupe = FileReadLine($fopen)
$groupeFQDN = _ad_SamAccountNameToFQDN($groupe)
$result = _AD_GetGroupMembers($groupeFQDN)


Local $groupdescription = _AD_GetObjectAttribute($groupeFQDN, 'description')

Same error

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
C:\Program Files (x86)\AutoIt3\Include\AD.au3 (4378) : ==> Variable must be of type "Object".:
Return $__oAD_OpenDS.OpenDSObject($sAD_FQDN, $sAD_UserId, $sAD_Password, $__bAD_BindFlags)
Return $__oAD_OpenDS^ ERROR

is there something wrong ?

Edited by rikho
Posted (edited)

WATER wrote :

It would be interesting to know wich function triggers the error.

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop

C:\Program Files (x86)\AutoIt3\Include\[color=#ff0000][b]AD.au3 (4378) : ==> Variable must be of type "Object".:[/b][/color]

Return $__oAD_OpenDS.OpenDSObject($sAD_FQDN, $sAD_UserId, $sAD_Password, $__bAD_BindFlags)
Return $__oAD_OpenDS^ ERROR
->10:19:39 AutoIT3.exe ended.rc:1

Which version of the UDF do you use (can be found in the header lines?)

; #INDEX# =======================================================================================================================

Title .........: Active Directory Function Library ;

AutoIt Version : 3.3.9.2 or later (because of _Date_Time_SystemTimeToDateTimeStr and the latest in COM error handling) ;

UDF Version ...: 1.3.0.0 ;

Language ......: English

Can you remove $sAD_DNSDomain, $sAD_HostServer, $sAD_Configuration from your script?

They are defined and used in the UDF itself.

Done. but same error appear. :(

another question

how to get the error return value

is the Function Returns value section of the help test :

; Return values .: Success - Value for the given attribute

; Failure - "", sets @error to:

; |1 - $sAD_Object does not exist

; |2 - $sAD_Attribute does not exist for $sAD_Object. @Extended is set to the error returned by LDAP

unfortunaltly, if got a error message, before i can do a msgbox of @error

Grrr....

Edited by rikho
Posted (edited)

In this case I need additional information.

Operating System? Windows 7, Windows XP ...

32 or 64 bit?

Which version of AutoIT? 3.3.8.1 ... I see you run 3.3.8.1

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

 

Posted

First we need to solve the crash before we can talk about how to get the error information returned in @error.

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

 

Posted

I wonder why the crashing statement is executed at all. This line is only run when _AD_Open is called with userid and password.

The code you posted has a simple _AD_Open(). Do you set variable $sAD_UserId anywhere in your script?

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

 

Posted (edited)

Do you set variable $sAD_UserId anywhere in your script?

Yes i defined it in the AD.AU3

64 bits OS

Global $sAD_HostServer = 'MYDC.MY.DOMAIN'

Global $sAD_Configuration

Global $sAD_UserId = 'myuser@my.domain'

Global $sAD_Password = '@Mypassword1234'

i've change this with

Global $sAD_DNSDomain = @LogonDNSDomain

Global $sAD_HostServer = @LogonServer

Global $sAD_Configuration

Global $sAD_UserId

Global $sAD_Password

To use current credential

actually i haven't got any error , anyway i can not _arraydisplay ($groupdescription) :(

i'm so stupid it mean the result is not an array ... am i tired ?

Edited by rikho
Posted

Please remove all $sAD_* variables from your script!

You need to pass them to _AD_Open because _AD_Open does some needed processing based on the parameters. That's why the error occurs.

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

 

Posted

i did it cause when i pass hem to _AD_Open i got somes error.

but it's now ok it work's perfectly

regard"s

Rikho

Posted

Glad the problem could be solved :D

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

 

Posted

no problem with all groups with description

if no desciption

C:\Program Files (x86)\AutoIt3\Include\AD.au3 (632) : ==> The requested action with this object has failed.:
Local $sAD_Result = $oAD_Object.Get($sAD_Attribute)
Local $sAD_Result = $oAD_Object.Get($sAD_Attribute)^ ERROR

Do you know how to test description attribute ?

Posted

Either run the script with the 3.3.9.2 version of AutoIt. Then such errors no longer crash the script.

Or add _AD_ErrorNotify(1) at the top of your script. It will handle the error and write a message to the Console.

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

 

Posted

Below the debug message error

========================================================

COM Error Encountered in Auditgroup_OK.au3

AD UDF version = 1.3.0

@AutoItVersion = 3.3.8.1

@AutoItX64 = 0

@Compiled = 0

@OSArch = X64

@OSVersion = WIN_7

Scriptline = 632

NumberHex = 80020009

Number = -2147352567

WinDescription =

Description = La propriété répertoire n’est pas présente dans le cache.

Source = Active Directory

HelpFile =

HelpContext = 0

LastDllError = 0

========================================================

What does that mean ?

Posted

It just means that the object you query doesn't have the specified property.

As your script no longer crashes simply ignore the message.

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

 

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
  • Recently Browsing   0 members

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