Share via


Getting the DNS Address of a Cluster Server

Getting the DNS Address of a Cluster Server

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following example returns the Domain Name System (DNS) address of the specified cluster server. This example uses a function for Getting the Property Value of a Cluster Resource.

Visual Basic

'//////////////////////////////////////////////////////////////////////
' Function: getIPAddress()
' Purpose:  Returns the DNS address of the specified cluster server.
'
' Input:    szIPname:                 DNS Address of cluster server
'
' Output:   getIPAddress:             Contains Error code (if any)
'           szIPaddr:                 IP address of specified server
'
' Note:  In order for this example to function correctly, it may be necessary to include
' references to the following libraries: Active DS Type Library, Microsoft CDO for
' Exchange Management Library, Microsoft Cluster Service Automation Classes,
' Microsoft CDO for Windows 2000 Library.
'//////////////////////////////////////////////////////////////////////
Public Function getIPAddress(ByVal szIPname As String, _
                             ByRef szIPaddr As String) As Integer

    Dim oCluster As New msclusterlib.Cluster
    Dim oGroup As msclusterlib.ClusResGroups
    Dim iGroupCount As Integer
    Dim szPropValue As String

    On Error GoTo errhandler

    oCluster.Open szIPname
    Set oGroup = oCluster.ResourceGroups
    szPropValue = ""

    For iGroupCount = 1 To oGroup.Count
        getPropertyValue oGroup(iGroupCount), "Network Name", "Name", szPropValue
        If UCase(szPropValue) = UCase(getTopLevelDomainName(szIPname)) Then
            getPropertyValue oGroup(iGroupCount), "IP Address", "Address", szPropValue
            szIPaddr = szPropValue
        End If
        Exit For
    Next

    getIPAddress = 0

    ' Clean up.
    Set oCluster = Nothing
    Set oGroup = Nothing
    Exit Function

    ' Error handling.
errhandler:

    Set oCluster = Nothing
    Set oGroup = Nothing
    getIPAddress = 1

End Function

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.