Creating a Cluster Resource
Creating a Cluster Resource
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 creates a cluster resource.
Visual Basic
'////////////////////////////////////////////////////////////////////// ' Function: createClusterResource() ' Purpose: Creates a cluster resource. ' ' Input: szClusterName: Name of cluster server to query ' szGroupName: Name of cluster group ' szHTTPInstanceName: Name of HTTP cluster resource being created ' szUserName: Admin username ' szPassword: Admin Password ' szEntryID: Entry ID of http resource ' ' Output: createClusterResource: Contains Error code (if any) ' ' 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 createClusterResource(ByVal szClusterName As String, _ ByVal szGroupName As String, _ ByVal szHTTPInstanceName As String, _ ByVal szUserName As String, _ ByVal szPassword As String, _ ByVal szEntryID As String) As Integer ' Setup error handler. On Error GoTo errhandler ' Declare objects. Dim oCluster As New msclusterlib.Cluster Dim oGroup As Variant Dim oNewResource As Variant Dim oResources As Variant Dim oDependencies As Variant Dim oProperties As Variant Dim iProtocolInstanceId As Integer Dim szClusterGroupName As String Dim iGroupCount As Integer Dim iResourceCount As Integer iProtocolInstanceId = Int(Val(szEntryID)) szClusterGroupName = "" oCluster.Open szClusterName ' Get the name of the group that the specified server belongs to. For iGroupCount = 1 To oCluster.ResourceGroups.Count For iResourceCount = 1 To oCluster.ResourceGroups(iGroupCount).Resources.Count If oCluster.ResourceGroups(iGroupCount).Resources(iResourceCount).TypeName = "Network Name" Then If UCase(oCluster.ResourceGroups(iGroupCount).Resources(iResourceCount).PrivateProperties(1).value) = UCase(szGroupName) Then szClusterGroupName = oCluster.ResourceGroups(iGroupCount).Name Exit For End If End If Next If szClusterGroupName <> "" Then Exit For End If Next Set oGroup = oCluster.ResourceGroups.Item(szClusterGroupName) Set oResources = oGroup.Resources Set oNewResource = oGroup.Resources.CreateItem(szHTTPInstanceName, "Microsoft Exchange DAV Server Instance", 0) Set oDependencies = oNewResource.Dependencies For Each oResources In oGroup.Resources If oResources.Type.Name = "Microsoft Exchange Information Store" Then oDependencies.AddItem oResources Exit For End If Next ' Set properties. Set oProperties = oNewResource.PrivateProperties With oProperties .Item("Password").value = szPassword .Item("LogonAccount").value = szUserName .Item("DSObjCreated").value = 1 .Item("ProtocolInstanceId").value = iProtocolInstanceId .Item("UseNetworkName").value = 1 .SaveChanges End With createClusterResource = 0 ' Clean up. Set oCluster = Nothing Set oGroup = Nothing Set oNewResource = Nothing Set oResources = Nothing Set oDependencies = Nothing Set oProperties = Nothing Exit Function ' Error handling. errhandler: Set oCluster = Nothing Set oGroup = Nothing Set oNewResource = Nothing Set oResources = Nothing Set oDependencies = Nothing Set oProperties = Nothing ' Implement error logging here. createClusterResource = 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.