请教wmi操作DNS的问题-创建辅助区域出错2003系统  zonetype为0 即主要区域时不出问题 但为1就出问题  参考MS的资料(如下)错误出在 IpAddr 我用VB写的 提示“类型不匹配”  请大家帮忙解决
CreateZone Method of the MicrosoftDNS_Zone Class
The CreateZone method creates a DNS zone.void CreateZone(
  string ZoneName,
  uint32 ZoneType,
  boolean DsIntegrated,
  string DataFileName,
  string IpAddr[],
  string AdminEmailName,
  MicrosoftDns_Zone& RR
);Parameters
ZoneName 
[in] String representing the name of the zone. 
ZoneType 
[in] Type of zone. Valid values are the following: Value Meaning 
0 Primary zone. 
1 Secondary zone. 
2 Stub zone. 
3 Zone forwarder. DsIntegrated 
[in] Indicates whether zone data is stored in the Active Directory or in files. If TRUE, the data is stored in the Active Directory; if FALSE, the data is stored in files. 
DataFileName 
[in, optional] Name of the data file associated with the zone. 
IpAddr 
[in, optional] IP address of the master DNS Server for the zone. 
AdminEmailName 
[in, optional] Email address of the administrator responsible for the zone. 
RR 
[out] RR of type MicrosoftDns_Zone. 
Return Values
This method has no return values. 
Requirements
Server Requires Windows Server "Longhorn", Windows Server 2003, or Windows 2000 Server. 
MOF Declared in Dnsprov.mof.
 
Namespace Defined in \\.\Root\MicrosoftDNS.

解决方案 »

  1.   

    我的代码Public Function CreateZone(ByVal sZoneName As Variant, ByVal sDataFileName As Variant, ByRef errMsg As Variant) As Variant
    dim ip(1) as string
    ip(0)="192.168.0.102"
    ip(1)="192.168.0.100"
    Set objinst = SelectRR("MicrosoftDNS_Zone", " ContainerName=" & Chr(34) & sZoneName & Chr(34), errMsg)
    If errMsg <> "" Then
    CreateZone = "Error:6003"
    Exit Function
    End IfIf objinst.Count > 0 Then
    errMsg = "该区域已存在"
    CreateZone = "Error:6002"
    Set objinst = Nothing
    Exit Function
    End IfSet objinst = Nothing
    ZoneType = 1
    Dim oParams As New Dictionary
    oParams.Add "ZoneName", sZoneName
    oParams.Add "ZoneType", ZoneType
    oParams.Add "DataFileName", sDataFileName
    oParams.Add "IpAddr", ip
    CreateZone = Create("MicrosoftDNS_Zone", "CreateZone", oParams, errMsg)
    Set oParams = Nothing
    End Function
    Private Function SelectRR(ByVal recordType As String, ByVal sFilterExpression As String, ByRef errMsg As Variant) As Object
    On Error GoTo ll
    errMsg = ""
    sql = "Select * from " & recordType
    If sFilterExpression <> "" Then
    sql = sql & " where " & sFilterExpression
    End If
    Set SelectRR = objService.ExecQuery(sql)
    errMsg = ""
    Exit Function
    ll: errMsg = Err.Description
    Set SelectRR = Nothing
    Err.Clear
    End FunctionPrivate Function Create(ByVal sTableName As String, ByVal MethodName As String, ByRef oParms As Dictionary, ByRef errMsg As Variant) As Variant
    On Error GoTo ll
    Set oProcess = objService.Get(sTableName)
    Set oInParams = oProcess.Methods_(MethodName).InParameters.SpawnInstance_()
    For Each Key In oParms.Keys
    oInParams.Properties_.Item(Key).Value = CStr(oParms.Item(Key))
    Next
    objService.ExecMethod sTableName, MethodName, oInParams
    errMsg = ""
    Create = "OK:6000"
    Exit Function
    ll:
    Create = "Error:6003"
    errMsg = Err.Description
    End Function