I am enumerating a Domain Local Group in Active Directory using:
Dim de As New DirectoryEntry("path")
Dim members As IADsMembers = DirectCast(de.Invoke("Members"), IADsMembers)
members.Filter = New Object() {"user"}
'Iterate over users.
members.Filter = New Object() {"group"}
'Iterate over nested groups.
The Domain Local Group is not enumerating. I have checked members.Count which equals 1.
Having looked in Active Directory there is a Foreign Security Principal which links to a Global Group in another domain. Research suggests that the only options for members.Filter are user and group, user and group.
How can I extract the Foreign Security Principal from this collection?
For the most part I have chosen to use the functionality provided by
System.Directory.AccountManagementin .NET 3.5 to enumerate a global group. If the object being enumerated is actually a Foreign Security Principal then the .NET 3.5 code does not suffice. Hopefully the following code will help someone else:There is probably better ways of doing this but it works.