Can anyone help translate this into C#??? It's supposed
to list all subnets in all AD sites (see URL below). I
placed it in a VB class library (one class with
one "Function", WScript.Echo replaced with a string
concat & return statement) and tried to reference it that
way, but I kept getting "object not an instance" errors.
Rather than try to debug that approach in that pea soup
language, I'd rather just rewrite it in C# so I can see
what the H is happening. Is this VB using
DirectoryServices or Management classes?
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get
("configurationNamingContext")
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," &
strConfigurationNC
Set objSubnetsContainer = GetObject(strSubnetsContainer)
objSubnetsContainer.Filter = Array("subnet")
Set objHash = CreateObject("Scripting.Dictionary")
For Each objSubnet In objSubnetsContainer
objSubnet.GetInfoEx Array("siteObject"), 0
strSiteObjectDN = objSubnet.Get("siteObject")
strSiteObjectName = Split(Split(strSiteObjectDN, ",")
(0), "=")(1)
If objHash.Exists(strSiteObjectName) Then
objHash(strSiteObjectName) = objHash
(strSiteObjectName) & "," & _
Split
(objSubnet.Name, "=")(1)
Else
objHash.Add strSiteObjectName, Split
(objSubnet.Name, "=")(1)
End If
Next
For Each strKey In objHash.Keys
WScript.Echo strKey & "," & objHash(strKey)
Next
The VB script was taken from this page:
http://www.microsoft.com/technet/treeview/default.asp?
url=/technet/ScriptCenter/network/scrnet24.asp