Retrieving msExchMDB via LDAP is not working RRS feed

  • Question

  • Hello,

    I'm unable to to retrieve all the available mail store on my Exchange server with (VS2010). I can get msExchExchangeServer objects just fine though. Any thoughts? I tried msExchPrivateMDB as well with no luck but, I can retrieve these objects in Vbscript

    Dim rootDSE As DirectoryEntry = New DirectoryEntry("LDAP://rootDSE")




    Dim configurationNamingContext As String = rootDSE.Properties("configurationNamingContext").Value.ToString()




    Dim SearchRoot As New DirectoryEntry("LDAP://" & configurationNamingContext)




    Dim Searcher As DirectorySearcher = New DirectorySearcher(SearchRoot)




    Dim ExchangeMDBs As SearchResultCollection



    Dim ExchangeMDB As SearchResult



    Dim myArray As New ArrayList()




    With Searcher

    .Filter =






    End With

    ExchangeMDBs = Searcher.FindAll



    If ExchangeMDBs.Count >= 1 Then



    For Each ExchangeMDB In ExchangeMDBs








    'myArray.Add(Result.GetDirectoryEntry().Properties("cn").Value) (cn=" & Trim(ddlMailServer.SelectedValue) & "*)







    lblMailStore_Error.Text =


    "There is no mail store available on this server. " & ddlMailServer.SelectedValue




    End If





    Set objRootDSE = GetObject("LDAP://rootDSE")
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
    With objCommand
     .Properties("Page Size") = 10000
     .Properties("Searchscope") = 2
     .Properties("Cache Results") = False
     .CommandText = "<LDAP://" &objRootDSE.get("configurationNamingContext") &">;(&(objectClass=msExchPrivateMDB));cn;subtree"
    End With
    Set objRecordSet = objCommand.Execute
    Do Until objRecordSet.EOF
     wscript.Echo objRecordSet.Fields("cn").value

    Tuesday, December 7, 2010 3:55 PM

All replies

  • anyone?
    Thursday, December 9, 2010 4:52 PM
  • You should use a code box when your posting any code i can't make sense of what you posted maybe try this instead

      ' Bind to the RootDSE to get the configurationNamingContext property.
      Dim RootDSE As New DirectoryEntry("LDAP://RootDSE")
      ' Bind to the Configuraiton container.
      Dim Path As String = "LDAP://" + RootDSE.Properties("configurationNamingContext").Value
      Dim ConfigContainer As New DirectoryEntry(Path)
      ' Search for an object that is of type crossRefContainer.
      Dim ConfigSearcher As New DirectorySearcher(ConfigContainer)
      ConfigSearcher.Filter = "(&(objectClass=msExchPrivateMDB))"
      ConfigSearcher.SearchScope = SearchScope.Subtree
      Dim results As SearchResultCollection = ConfigSearcher.FindAll()



    Friday, December 10, 2010 2:32 AM