G
ginolard
I'm trying to convert some code from VBscript to VB.Net and am getting
stuck on how it works with Active Directory.
I need to get a list of domains in the current forest. What's wrong
with my code?
Dim objRootLDAP
objRootLDAP = GetObject("LDAP://RootDSE")
Dim de As New
System.DirectoryServices.DirectoryEntry("LDAP://CN=Partitions," +
objRootLDAP.Get("ConfigurationNamingContext"))
Dim ds As New System.DirectoryServices.DirectorySearcher(de)
Dim r As System.DirectoryServices.SearchResult
ds.Filter = "(&(objectcategory=crossRef)(systemFlags=3))"
ds.SearchScope = SearchScope.OneLevel
ds.PropertiesToLoad.Add("nCName")
For Each r In ds.FindAll
Console.WriteLine(r.GetDirectoryEntry.Name.ToString)
Next
stuck on how it works with Active Directory.
I need to get a list of domains in the current forest. What's wrong
with my code?
Dim objRootLDAP
objRootLDAP = GetObject("LDAP://RootDSE")
Dim de As New
System.DirectoryServices.DirectoryEntry("LDAP://CN=Partitions," +
objRootLDAP.Get("ConfigurationNamingContext"))
Dim ds As New System.DirectoryServices.DirectorySearcher(de)
Dim r As System.DirectoryServices.SearchResult
ds.Filter = "(&(objectcategory=crossRef)(systemFlags=3))"
ds.SearchScope = SearchScope.OneLevel
ds.PropertiesToLoad.Add("nCName")
For Each r In ds.FindAll
Console.WriteLine(r.GetDirectoryEntry.Name.ToString)
Next