Jump to content

Recommended Posts

Hi everybody

First, sorry for my bad english.

Second, i need to list members of a group in Active Directory.

I read this topic and i use this script :

#include <array.au3> ; For _ArrayDisplay()
#include <adfunctions.au3>

Dim $sGroup_Name = "my group"
Dim $avList_Of_Members

_ADGetGroupMemberOf ($avList_Of_Members, $sGroup_Name)
_ArrayDisplay($avList_Of_Members, "Members of group: " & $sGroup_Name)oÝ÷ Ø­'(Ê%z·­º¹Þ®º+jëh×6>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Backup_DD_Externe\AutoIt Development\Send_Mailing\test.au3"    
C:\Program Files\AutoIt3\Include\adfunctions.au3 (472) : ==> Object referenced outside a "With" statement.:
$membersadd = $objRecordSet.fields (0).Value
$membersadd = $objRecordSet.fields (0)^ ERROR
>Exit code: 1    Time: 0.739oÝ÷ Ù©ÝêÞËayÆ¥ç_ºw-ÚºÚ"µÍÈÐQÙ]ÜÝY[XÙ[ÈÐQÙ]ÜÝY[XÙTY ÌÍÛY[XÙ ÌÍÙÜÝ  ÌÍÜÛÜH
BSØØ[ ÌÍÛÕÜ  ÌÍÛØÛÛ[X[ ÌÍÙÜÝË    ÌÍÛY[XØYIÌÍÛØÛÛ[X[HØÜX]J    ][ÝÐQÑÛÛ[X[    ][ÝÊBIÌÍÛØÛÛ[X[XÝ]PÛÛXÝ[ÛH ÌÍÛØÛÛXÝ[ÛIÌÍÛØÛÛ[X[ÜYÈ
    ][ÝÔÙXÚØÛÜI][ÝÊHHBQ[H  ÌÍÛY[XÙÌWBIÌÍÚHHUÚ[HBBIÌÍÜ[Ù[[ÙYYH    ÌÍÚH
LBIÌÍÜ[ÙHH  ][ÝÔ[ÙOI][ÝÈ   [È ÌÍÜ[Ù[[ÙYY [È ][ÝËI][ÝÈ   [È ÌÍÜ[Ù[[ÙYY
ÈNNBBIÌÍÜÝÛY^H    ][ÝÉÓTËÉ][ÝÈ [È ÌÍÜÝÜÝÙ  [È ][ÝËÉ][ÝÈ  [È ÌÍÙÜÝ  [È ][ÝÉÝÎÎÛY[XÙÉ][ÝÈ [È ÌÍÜ[ÙH  [È ][ÝÎØÙI][ÝÂBIÌÍÛØÛÛ[X[ÛÛ[X[^H ÌÍÜÝÛY^BIÌÍÛØXÛÜÙ]H ÌÍÛØÛÛ[X[^XÝ]BBIÌÍÛY[XØYH    ÌÍÛØXÛÜÙ]Y[È

K[YBBRY ÌÍÛY[XØYH[^]ÛÜBTQ[H   ÌÍÛY[XÙÕPÝ[
    ÌÍÛY[XÙH
ÈLBBQÜ    ÌÍÚH ÌÍÜ[Ù[[ÙYY
ÈHÈ   ÌÍÜ[Ù[[ÙYY
ÈLBBIÌÍÛY[XÙÉÌÍÚHH ÌÍÛY[XØYÉÌÍÚH   ÌÍÜ[Ù[[ÙYYHWBBS^BIÌÍÚH
ÏHBBIÌÍÛØXÛÜÙ]ÛÜÙBUÑ[IÌÍÜ[Ù[[ÙYYH  ÌÍÚH
LIÌÍÜ[ÙHH   ][ÝÔ[ÙOI][ÝÈ   [È ÌÍÜ[Ù[[ÙYY [È ][ÝËJ][ÝÂIÌÍÜÝÛY^H ][ÝÉÓTËÉ][ÝÈ [È ÌÍÜÝÜÝÙ  [È ][ÝËÉ][ÝÈ  [È ÌÍÙÜÝ  [È ][ÝÉÝÎÎÛY[XÙÉ][ÝÈ [È ÌÍÜ[ÙH  [È ][ÝÎØÙI][ÝÂIÌÍÛØÛÛ[X[ÛÛ[X[^H  ÌÍÜÝÛY^IÌÍÛØXÛÜÙ]H  ÌÍÛØÛÛ[X[^XÝ]BIÌÍÛY[XØYH ÌÍÛØXÛÜÙ]Y[È

K[YNÏOIÝÈSH

ÂTQ[H  ÌÍÛY[XÙÕPÝ[
    ÌÍÛY[XÙH
ÈPÝ[
    ÌÍÛY[XØY
HBQÜ   ÌÍÚH ÌÍÜ[Ù[[ÙYY
ÈHÈ   ÌÍÜ[Ù[[ÙYY
ÈPÝ[
    ÌÍÛY[XØY
BBIÌÍÛY[XÙÉÌÍÚHH    ÌÍÛY[XØYÉÌÍÚH   ÌÍÜ[Ù[[ÙYYHWBS^IÌÍÛØXÛÜÙ]ÛÜÙBBIÌÍÛØÛÛ[X[HIÌÍÛØXÛÜÙ]HBIÌÍÛY[XÙÌHHPÝ[
    ÌÍÛY[XÙHHBBRY   ÌÍÜÛÜHH[BWÐ^TÛÜ
    ÌÍÛY[XÙJBQ[YBT] ÌÍÛY[XÙÌBB[[ÈÏOIÝ×ÐQÙ]ÜÝY[XÙ

Someone can help me please ?

Thank you

Edited by lafafmentvotre
Link to post
Share on other sites

Your code looks a bit scrambled at the end

#include <array.au3> ; For _ArrayDisplay()

#include <adfunctions.au3>

Dim $sGroup_Name = "my group"

Dim $avList_Of_Members

_ADGetGroupMemberOf ($avList_Of_Members, $sGroup_Name)

_ArrayDisplay($avList_Of_Members, "Members of group: " & $sGroup_Name)

oÝ÷ Ù»­y²rì¢W­êÞƧzºè­«­¢+ØÐìÅÕ½Ðí

But from what I can see you use adfunctions.au3 which should make it very easy to do what you want.

Can you describe more in detail what your problem is? Doesn't your script return any records? Do you get a COM error? ...

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Do you use the full qualified name of the group (e.g. CN=groupname,OU=Example_Group,DC=microsoft,DC=com)?

If not you can translate the "short name" (samAcocuntName) to a FQDN.

$sGroup_Name = _ADSamAccountNameToFQDN("my 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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Hello

Must i have to modify this lines in adfunctions.au3 with my AD config ?

Global $objRootDSE = ObjGet("LDAP://RootDSE")
Global $strDNSDomain = $objRootDSE.Get ("defaultNamingContext")  ; Retrieve the current AD domain name
Global $strHostServer = $objRootDSE.Get ("dnsHostName") ; Retrieve the name of the connected DC
Global $strConfiguration = $objRootDSE.Get ("ConfigurationNamingContext") ; Retrieve the Configuration naming context
Link to post
Share on other sites

Must i have to modify this lines in adfunctions.au3 with my AD config ?

No, your script can be as short as:

#include <array.au3> 
#include <adfunctions.au3>

Dim $avList_Of_Members
Dim $sGroup_Name = _ADSamAccountNameToFQDN("my group")

_ADGetGroupMemberOf ($avList_Of_Members, $sGroup_Name)
_ArrayDisplay($avList_Of_Members, "Members of group: " & $sGroup_Name)

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

It doesn't work and this the same error msg :

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Backup_DD_Externe\AutoIt Development\Send_Mailing\test.au3"    
C:\Program Files\AutoIt3\Include\adfunctions.au3 (472) : ==> Object referenced outside a "With" statement.:
$membersadd = $objRecordSet.fields (0).Value
$membersadd = $objRecordSet.fields (0)^ ERROR
>Exit code: 1    Time: 0.428
Link to post
Share on other sites

Sorry, my fault.

i need to list members of a group in Active Directory.

You have to use function _ADGetGroupMembers not _ADGetGroupMemberOf. So your script should now look like:

#include <array.au3> 
#include <adfunctions.au3>

Dim $avList_Of_Members
Dim $sGroup_Name = _ADSamAccountNameToFQDN("my group")

_ADGetGroupMembers ($avList_Of_Members, $sGroup_Name)
_ArrayDisplay($avList_Of_Members, "Members of group: " & $sGroup_Name)

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

You have to use function _ADGetGroupMembers not _ADGetGroupMemberOf. So your script should now look like:

Hi

Same error :

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Backup_DD_Externe\AutoIt Development\Send_Mailing\test.au3"    
C:\Program Files\AutoIt3\Include\adfunctions.au3 (418) : ==> Object referenced outside a "With" statement.:
$membersadd = $objRecordSet.fields (0).Value
$membersadd = $objRecordSet.fields (0)^ ERROR
>Exit code: 1    Time: 0.527

The error is in adfunctions.au3 not in my test script.

thanks for help

Link to post
Share on other sites

Could you please run the following script to test the existance of your group? Set $sGroup_Name to SamAccountName (the one without CN= ...) of your group.

#include <array.au3> ; For _ArrayDisplay()
#include <adfunctions.au3>

Dim $sGroup_Name = 'Your groupname'
Dim $avList_Of_Members

If _ADObjectExists($sGroup_Name) = 1 Then
    MsgBox(0,"","Group " & $sGroup_Name & " exists!")
Else
    MsgBox(0,"","Group " & $sGroup_Name & " does not exist!")
    Exit
EndIf
$sGroup_Name = _ADSamAccountNameToFQDN($sGroup_Name)
_ADGetGroupMembers ($avList_Of_Members, $sGroup_Name)
_ArrayDisplay($avList_Of_Members, "Members of group: " & $sGroup_Name)

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

You could use something like

#include <array.au3>
#include <adfunctions.au3>

Dim $avList_Of_Members
Dim $sOU = "OU=xy,OU=123,OU=User_Accounts,DC=microsoft,DC=com"
_ADGetObjectsInOU($avList_Of_Members, $sOU)

_ArrayDisplay($avList_Of_Members, "Members of OU: " & $sOU)

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

CODE: AutoIt

#include <array.au3>

#include <adfunctions.au3>

Dim $avList_Of_Members

Dim $sOU = "OU=xy,OU=123,OU=User_Accounts,DC=microsoft,DC=com"

_ADGetObjectsInOU($avList_Of_Members, $sOU)

_ArrayDisplay($avList_Of_Members, "Members of OU: " & $sOU)

I change $sOU value with my config and I test it but it doesn't work. This is the error msg :

We intercepted a COM Error !

Number is: 000000A9

Windescription is: Variable must be of type 'Object'.

Script Line number is: 641

I think le line 641 is in adfunctions.au3 and this is the line :

$recordcount = $objRecordSet.RecordCount

Help me please

Thanks

Edited by lafafmentvotre
Link to post
Share on other sites

You get this error message when the OU-string is not correct. Could you please post the complete OU string you use (if you want you can change some letters but please don't change the OU=..,DC=... format).

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Your OU-string looks fine.

Another question: which version of adfunctions do you use? The latest version I've found can be donwloaded from here. In an old version there seemed to be a problem with _ADGetObjectsInOU.

Could you please download the latest version and give it a try?

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Hi, the adfunctions udf you downloaded is quite old and might have the bug I was talking about.

I've corrected the link in my previous post. Could you please download this version and try again?

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

    No registered users viewing this page.

×
×
  • Create New...