How to list the memberof values of a group

464 views Asked by At

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?

1

There are 1 answers

0
Frans On

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.