Sylv4n (TechnicalUser) (OP)
6 Oct 08 9:33
I'm trying to get all the members of a group. most of the groups are in the Dept OU but there are some elsewhere.
I am using VBA behind a Excel worksheet
I have the following syntax that works:
Public Function getUsersInGroup(strGroup As String)
Dim myResults() As String
Set objGroup = GetObject("LDAP://CN=" & strGroup & ",OU=Finance,OU=Dept,DC=myCompany,DC=com")
If objGroup.members.Count > 0 Then
ReDim myResults(objGroup.members.Count - 1, 1)
myCount = 0
For Each objUser In objGroup.members
myResults(myCount, 0) = objUser.sAMAccountName
myResults(myCount, 1) = objUser.DisplayName
myCount = myCount + 1
now the problem I have is that not all the departments I want to look are are in the Finance OU, so I want something like:
Set objGroup = GetObject("LDAP://CN=" & strGroup & ",OU=Dept,DC=myCompany,DC=com");subtree
or even better would be to not specify the OU at all and have it search all OU's, this kind of solution would be ideal, so something like
Set objGroup = GetObject("LDAP://CN=" & strGroup & ",DC=myCompany,DC=com");subtree
but every thime I try and add the subtree in it wont work.
Any ideas how I can do this?