How to get user's mailbox store server on an Exchange cluster? RRS feed

  • Question

  • Hi, I have a client with an exchange cluster that has 2 active and 2 passive nodes. I need to find out the specific machine that a user's mailbox is on, but when I use LDAP to get the "homeMDB" attribute, I get the name of the virtual server. Environment is VS2005 and Win2003 and Exchange 2003.

    Within a .NET application, is there any good way to find out the machine name that actually has the user's mailbox?



    PS. Below is the code I have which works for non-clustered Exchange servers:

     Public Function GetServerByUserMailbox(ByVal UserName As String) As String _
            Implements IPSTAuthenticate.GetServerByUserMailbox


                Dim entryDomain As DirectoryEntry
                Dim search As DirectorySearcher
                Dim domainName As String

                domainName = GetServerDomain()
                entryDomain = New DirectoryEntry("LDAP://" + domainName)
                search = New DirectorySearcher(entryDomain)
                search.Filter = "(&(objectClass=user)(sAMAccountName=" & UserName & "))"
                search.SizeLimit = 2
                Dim result As SearchResult
                Dim hMDB As Object
                hMDB = String.Empty
                Dim retVal As String
                retVal = String.Empty

                result = search.FindOne()

                If Not (result Is Nothing) Then

                    If result.Properties.Contains("homeMDB") Then
                        hMDB = result.Properties("homeMDB").Item(0)
                        'regex to find the actual mailbox store server
                        Dim customMatch As Match

                        customMatch = System.Text.RegularExpressions.Regex.Match(hMDB, "(?<=(Mailbox\s*Store\s*\()).*?(?=(\)))", _
                                                System.Text.RegularExpressions.RegexOptions.IgnoreCase _
                                                        Or System.Text.RegularExpressions.RegexOptions.Multiline)

                        If Not (customMatch Is Nothing) And customMatch.Success Then
                            retVal = customMatch.Value
                        End If

                    End If
                End If
                Return retVal
            Catch ex As Exception
                LogFile(-999, "Error getting user's mailbox store: " & ex.ToString(), _
                                    "GetUserMailBoxServer", "UserName: " & UserName)

                Return String.Empty
            End Try

    End Function
    Wednesday, September 5, 2007 6:37 PM