Hi,
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:
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:
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
but every thime I try and add the subtree in it wont work.
Any ideas how I can do this?
Thanks
Sylvan
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:
Code:
Public Function getUsersInGroup(strGroup As String)
Dim myResults() As String
Dim objGroup
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
Next
End If
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:
Code:
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
Code:
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?
Thanks
Sylvan