If I understand you correctly, you are starting with one user account and you want to:
- Get all the groups that user is a member of (by getting the value of
'memberOf')
- Find the members of each group found in step 1.
There are two ways you can do this:
- Iterate through all the groups and make a separate call to get the 'member' attribute, which will have the list of members.
- Construct a query based on 'memberOf' to find all other people who are members of the same groups:
(&(objectClass=user)(|(memberOf=CN=group1,OU=something,DC=mydomain,DC=com)(memberOf=CN=group2,OU=something,DC=mydomain,DC=com)(memberOf=CN=group3,OU=something,DC=mydomain,DC=com)))
It is possible to get different results based on which method you use.
Method 1 will get you any members of the groups, even if they're on other domains outside the domain or forest (for example, domains with one-way trusts).
With method 2 (searching memberOf) your results will be different if you search using LDAP:// (port 389) or GC:// (port 3268). Using GC:// will not work for global or domain local groups, whereas using LDAP:// will. However, if you use LDAP:// you will only get users from one domain, which might be a problem if you have other domains in your AD forest.
If you only have 1 domain in your organization with no trusts to other domains, then you are better off using LDAP://.