Where i made an error?

  • Thread starter Thread starter Leszek Gruszka
  • Start date Start date
L

Leszek Gruszka

I wrote this code:
But somewhere i made a mistake...


Try
Dim objRootDSE = GetObject(LDAP://RootDSE)
Dim strConfigurationNC = objRootDSE.Get("configurationNamingContext")
Dim strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC
Dim objSubnetsContainer = GetObject(strSubnetsContainer)
Dim array(0) As String
Dim objsubnet, strSiteObjectDN, strSiteObjectName, strKey
array(0) = "subnet"
objSubnetsContainer.Filter = array
Dim 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
MsgBox(strKey & "," & objHash(strKey))
Next
Catch ex As Exception
System.Console.WriteLine(ex.Message)
End Try
 
Leszek,
Is this a VB.NET question? As this is a VB.NET newsgroup.

Your sample appears to be VBScript or VB6.

If this is a VB.NET question:

Can you better describe what the error is, and what you are expecting as a
result?

One place you may want to start is adding Option Strict On at the top of
your source file. This will cause compile time errors that generally are
easier to fix then runtime errors.

Also rather then rely on VB6 & VBScript COM components you may want to look
at the System.DirectoryServices Namespace and System.Collections.HashTable.

Hope this helps
Jay
 
Back
Top