Where i made an error?

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
 
R

Robin Tucker

lol - hehe. Its possible your tutor made an error and has asked you to find
it.
 
J

Jay B. Harlow [MVP - Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top