Hey everyone,
I am writing a .net class library for use here at work in C#. The class I am working on right now manages our local DNS Server through WMI. One method is supposed to add a new root level zone to the server. It works but it is only doing half the job - it doesn’t define the start of authority (SOA) for the newly created zone. When I view the new zone on the server through the DNS Manager it gives me a "Zone not loaded by DNS Server" error message. Here is my code for the method. I have been searching for a solution but now I've waited half the day looking through useless articles for an example or explanation - so any help would be much appreciated!!
-----------------------------------------------------------------------BEGIN CODE
using System;
using System.Management;
public void AddDomain(string domainName,string ipDestination)
{
//check if domain already exists
if(this.DomainExists(domainName))
{
throw new Exception("The domain you are trying to add already exists on this server!");
}
//generate zone
ManagementClass man=this.Manage("MicrosoftDNS_Zone");
ManagementBaseObject ret=null;
ManagementBaseObject obj=man.GetMethodParameters("CreateZone");
//obj["StartOfAuthority"]=this.Server;
obj["OwnerName"]=domainName;
obj["ZoneName"]=domainName;
obj["DataFileName"]=domainName + ".dns";
obj["ZoneType"]=1;
obj["AdminEmailName"]="support@coactivesys.com";
obj["IpAddr"]=new string[]{"10.1.1.188"};
//invoke method, capture resource record, dispose unneccesary vars
ret=man.InvokeMethod("CreateZone",obj,null);
this.Dispose(ref obj);
//append to insert soa
// ret["DnsServerName"]=this.Server;
// ret["ContainerName"]=domainName;
this.Dispose(ref ret);
this.Dispose(ref man);
}

System.Management - SOA problem Adding DNS Zone to remote server
Ping Wang
Hey again, I found a solution to my problem. Ive posted the solution here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=464402&SiteID=1