Forum Discussion

TomGriffith3's avatar
TomGriffith3
Brass Contributor
Aug 09, 2022

Find members of O365 Group with vba?

Hello. If you have a minute, I used to use LDAP to query proxyAddress for specific (on-prem) AD user accounts. Now I was trying to query O365 groups for members. However, I think LDAP is out. At least when I try objectCategory='Group' on the same instance, I don't return the groups which I see in GAL on my outlook client. I guess there would be a way if vba creates an outlook instance, etc to read the GAL. Is there any way to query O365 group members from cloud AD in server based code? thank you very much.

1 Reply

  • TomGriffith3's avatar
    TomGriffith3
    Brass Contributor

    Hello. More info. When I try

    SELECT CN, memberOf FROM 'LDAP://blah.com' WHERE objectCategory="User"

    Do Until objResultSet.EOF
    currName=objResultSet.Fields("CN").Value

    If currName="Joe Smith" Then
    grpNameArray=objRecordSet.Fields("memberOf").Value
    Forall thingies in grpNameArray
    Print thingies
    End Forall
    End If

    The grpNameArray above, for Joe Smith memberOf, contains four items with CN=..., O=..., OU=...etc attributes.

    However, these don't match the three groups which are listed under Member Of tab when I right click Joe Smith and select properties in the GAL. They seem related but the CN doesn't exactly match the GAL name and the code returns four items when only three groups are listed under his properties. Could somebody explain this and is it possible to access the, presumably, O365 groups listed in his GAL account. thank you so much again.

Resources