Jump to content
Sign in to follow this  
lafafmentvotre

_ADGetGroupMemberOf

Recommended Posts

lafafmentvotre

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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

Your code looks a bit scrambled at the end

Sorry, the topic is ok now.

Someone can help me please ?

Edited by lafafmentvotre

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

Hi water

My group exist, your script is ok.

I have just realized that i confuse GROUP and OU.

My request for the topic is to list members for an ACTIVE DIRECTORY OU.

Is it possible with adfunctions.au3 ?

Really i'm sorry for this error

Thanks

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

Hello

Here it is :

OU=S1761,OU=LMC,OU=Users,OU=AD,DC=fr,DC=rcc

I have this line from AD Schema

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

Hello

Thanks for responses.

I take adfunctions.au3 ont this topic

and your link doesn't work

Edited by lafafmentvotre

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lafafmentvotre

Hi Water

Thank you.

I try this monday morning.

Have a good week end

Share this post


Link to post
Share on other sites
lafafmentvotre

Hi Water

It's ok for me. The new adfunctions.au3 run.

Thank you for your help

Have a nice day

Share this post


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
Sign in to follow this  

×