I am trying to obtain the default naming context in the most efficient way possible short of hard coding it :-)
This is from the Active Directory Cookbook and of course works as expected
CODE
Sub Main()
Dim objRootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim strAttrName As String
Dim objValue As Object
For Each strAttrName In objRootDSE.Properties.PropertyNames
For Each objValue In objRootDSE.Properties(strAttrName)
Console.WriteLine(strAttrName & " : " & objValue.ToString)
Next objValue
Next strAttrName
End Sub
It prints amongst other things:
...
defaultNamingContext : DC=Corp,DC=com
...
Since at this time I am only interested the defaultNamingContext value I tried
CODE
Sub Main()
Dim objRootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim strAttrName As String
Dim objValue As Object
strAttrName = "defaultNamingContext"
objValue = objRootDSE.Properties(strAttrName)
console.writeline(objValue.ToStrint)
End Sub
Which printed
System.DirectoryServices.PropertyValueCollection
I do not understand why is it printing what it is instead of it's value
Mr Ed