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

发布于 2024-07-20 05:31:16 字数 701 浏览 3 评论 0原文

以前有人在 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

有人有任何想法吗?

谢谢

Has anyone used the WMI ChangeZoneType DNS command in C#\VB.net before. I get an incorrect parameter exception when i try and invoke the changezonetype command. I get the dns zone that i want to change from the dns server (via query), set the zonetype to the appropriate uint value but am then getting the exception. I am trying to change the zone from secondary to primary and according to MSDN all the other values are optional (and as far as i am aware are needed when you want to change from primary to secondary) so i have not included them.

Below is the code that i am using....

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

Anyone got any ideas?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最初的梦 2024-07-27 05:31:16

在寻找了一些答案后,我尝试了以下方法并且它有效。

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

尼尔

After looking around for some answers i tried the following and it worked.

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

Niall

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文