2

Windows アプリケーションにこのコードを提供し、Windows サーバー 2019 に DNS ゾーンを追加できます。

string site = "domain.com";
ConnectionOptions co = new ConnectionOptions();
ManagementScope _scope =new ManagementScope(String.Format(@"\\{0}\root\MicrosoftDNS", System.Net.Dns.GetHostName()), co);
_scope.Connect();
ManagementObject mc = new ManagementClass(_scope, new ManagementPath("MicrosoftDNS_Zone"), null);
mc.Get();
ManagementBaseObject parameters = mc.GetMethodParameters("CreateZone");
parameters["ZoneName"] = site;
parameters["ZoneType"] = (UInt32) DNSServer.NewZoneType.Primary;
parameters["DsIntegrated"] = 0; //false
ManagementBaseObject createdEntry = mc.InvokeMethod("CreateZone", parameters, null);

Web アプリケーション (asp.net) で現在のコードを使用しようとすると、機能しません。

System.Management.ManagementException: 一般的なエラー

このエラーに変更@"\\{0}\Root\MicrosoftDNS"すると、次のように表示されます。@"\\{0}\root\cimv2"

System.Management.ManagementException: 見つかりません

私の物理パスでは、提供された許可は次のとおりです。

ここに画像の説明を入力

Windows認証を次のように設定しても:

<security>
      <authentication>
        <anonymousAuthentication enabled="false"/>
        <windowsAuthentication enabled="true"/>
      </authentication>
    </security>

ここに画像の説明を入力

また、ここで WMI にアクセス許可を設定します ここに画像の説明を入力

RPC を確認しましたが、正常に動作しています

ここに画像の説明を入力

また、この接続のアドレスをDNSに登録することを確認しました

ここに画像の説明を入力

ここMicrosoft Forumsでは、結果のない同じ質問を見ることができます。

4

0 に答える 0