代码之家  ›  专栏  ›  技术社区  ›  Niall Gray

使用WMI ChangeZoneType将DNS区域从辅助更改为主

  •  2
  • Niall Gray  · 技术社区  · 17 年前

    以前是否有人在C#\VB.net中使用过WMI ChangeZoneType DNS命令。当我尝试调用changezonetype命令时,我得到一个不正确的参数异常。我从dns服务器(通过查询)获取要更改的dns区域,将zonetype设置为适当的uint值,但随后将获得异常。我正在尝试将分区从次要改为主要,并根据 MSDN 所有其他值都是可选的(据我所知,当您想从主值更改为辅助值时,需要这些值),因此我没有包括它们。

            For Each DNSZone As ManagementObject In mgrZones
                mngrZones = DNSZone.GetMethodParameters("ChangeZoneType")
                mngrZones("ZoneType") = System.Convert.ToUInt32(zoneType)
                DNSZone.InvokeMethod("ChangeZoneType", mngrZones, Nothing)
            Next
    

    有人有什么想法吗?

    谢谢

    1 回复  |  直到 17 年前
        1
  •  1
  •   Niall Gray    17 年前

    enter code here
        For Each DNSZone As ManagementObject In mgrZones            
             DNSZone("zonetype") = 1 'sets it to primary
             DNSZone.Put()
       Next
    

    尼尔