A
Anonymous
Hi!
I would like to access the AD from Visual Basic and get me information about
groups and group members. All this works quite well, except for the problem
that I cannot read the members of a group of computers. Here's the code,
that might illuminate the picture somewhat (cutout, so probably not
executable!)
Private Sub UpdateADUsers(ByVal Ort As String)
Dim OU As IADsContainer
Dim GRP As IADsGroup
Dim Memberlist As IADsMembers
Dim Item, GRPMember As IADs
Dim hostname, Zeichen, GruppenMitglied As String
Dim Gruppe, Member As Variant
Set OU = GetObject("LDAP://" & Ort)
For Each Item In OU
If Item.Class = "group" Then
Set GRP = GetObject("LDAP://" & Item.Name & ", " & Ort)
Set Memberlist = GRP.Members
For Each Member In Memberlist
Debug.Print "Mitglied gefunden: " & Member & crlf
Next
End If
Next
'(...)
End Sub
The problem is, that "Memberlist" is always empty, if it I#m accessing a
group, which groups computers, e.g. the group "Domain Computers" or "Domain
Controllers". If I run the above code step by step in the Debug mode step
by, I can see that VB accesses the correct AD Object successfully, which
proves to me that the access is generally working well. I can read the
members of a group with the above code if the members are users (e.g. Group
"Domain Users"). But if the members are just computers, I get back an empty
list.
Any hints are welcome!
Thanks in advance!
Regards, T.
I would like to access the AD from Visual Basic and get me information about
groups and group members. All this works quite well, except for the problem
that I cannot read the members of a group of computers. Here's the code,
that might illuminate the picture somewhat (cutout, so probably not
executable!)
Private Sub UpdateADUsers(ByVal Ort As String)
Dim OU As IADsContainer
Dim GRP As IADsGroup
Dim Memberlist As IADsMembers
Dim Item, GRPMember As IADs
Dim hostname, Zeichen, GruppenMitglied As String
Dim Gruppe, Member As Variant
Set OU = GetObject("LDAP://" & Ort)
For Each Item In OU
If Item.Class = "group" Then
Set GRP = GetObject("LDAP://" & Item.Name & ", " & Ort)
Set Memberlist = GRP.Members
For Each Member In Memberlist
Debug.Print "Mitglied gefunden: " & Member & crlf
Next
End If
Next
'(...)
End Sub
The problem is, that "Memberlist" is always empty, if it I#m accessing a
group, which groups computers, e.g. the group "Domain Computers" or "Domain
Controllers". If I run the above code step by step in the Debug mode step
by, I can see that VB accesses the correct AD Object successfully, which
proves to me that the access is generally working well. I can read the
members of a group with the above code if the members are users (e.g. Group
"Domain Users"). But if the members are just computers, I get back an empty
list.
Any hints are welcome!
Thanks in advance!
Regards, T.