0

Please note! I do not want to find out the user/members of a group but the groups of which a selected group is a member of.

And I have this query which is accepted by the ADS as a valid question:

"SELECT Name,DistinguishedName,description,whenChanged,whenCreated,memberof FROM 'LDAP://" & SDomain &"' WHERE objectCategory = 'group' AND name ='" & group & "'"

However, when I try to read the values ​​stored in string (array?) "memberof", I can't. In many of our cases these are empty or single and sometimes also multiple values. And the script gets an error on the empty ones.

    memberof=""
    numberOfMemberships=0
    memberships=oRS0.Fields("memberof")
    For each ADSgroup in memberships
        memberof= memberof & ADSgroup & ";" 
        numberOfMemberships=numberOfMemberships+1
    Next    

I get "Microsoft VBScript runtime error '800a01c3' Object not a collection"

triggerd by line:

For each ADSgroup in memberships

Do any of you have any idea what I'm doing wrong here?

user692942
  • 16,398
  • 7
  • 76
  • 175
Frans
  • 3
  • 3
  • I'm sure [`memberOf`](https://learn.microsoft.com/en-us/windows/win32/ad/group-objects) is an object reference to a collection so trying to compare it as a string is definitely going to result in a type mismatch error. There is a good example here of working with nested groups - [VBScript - Retrieving a user's nested groups and getting rid of repetitions](https://stackoverflow.com/q/26116292). – user692942 Oct 16 '20 at 09:27

1 Answers1

0

Yes I've found the answer to my own question. Adding the IsNull chek solved it:

memberof=""
numberOfMemberships=0
memberships=oRS0.Fields("memberof")
if not IsNUll(memberships) then
    For each ADSgroup in memberships
       memberof= memberof & ADSgroup & ";" 
       numberOfMemberships=numberOfMemberships+1
    Next
end if 

Thanks anyway.

Frans
  • 3
  • 3