H
huang hspeeder via DotNetMonster.com
HI
I try it code only creat DNS ResourceRecord,How to creat dns zone?
thanks!
this code:
public void CreateRR(string zoneName, string rrTextRep)
{
if ( zoneName == null )
throw new ArgumentNullException("zoneName", "zoneName is null.");
if ( rrTextRep == null )
throw new ArgumentNullException("rrTextRep", "rrTextRep is null.");
InvokeMethodOptions options = new InvokeMethodOptions();
options.Timeout = new TimeSpan(0,0,0,5);
ManagementClass rrClass = new
ManagementClass(@"\\"+ System.Environment.MachineName
+@"\root\MicrosoftDNS","MicrosoftDNS_ResourceRecord",null);
//Get an input parameters object for this method
ManagementBaseObject inParams =
rrClass.GetMethodParameters("CreateInstanceFromTextRepresentation");
//Fill in input parameter values
inParams["DnsServerName"] = null; //Don't need.
inParams["ContainerName"] = zoneName;
inParams["TextRepresentation"] = rrTextRep;
//Execute the method
try
{
ManagementBaseObject outObject = rrClass.InvokeMethod
("CreateInstanceFromTextRepresentation", inParams, null);
PropertyDataCollection outProperties = outObject.Properties;
foreach (PropertyData outProperty in outProperties)
{
Console.WriteLine("Property = " + outProperty.Name);
}
}
catch
{
throw new ApplicationException
("CreateInstanceFromTextRepresentationmethod failed.");
}
} // End CreateInstanceFromTextRepresentation Method.
I try it code only creat DNS ResourceRecord,How to creat dns zone?
thanks!
this code:
public void CreateRR(string zoneName, string rrTextRep)
{
if ( zoneName == null )
throw new ArgumentNullException("zoneName", "zoneName is null.");
if ( rrTextRep == null )
throw new ArgumentNullException("rrTextRep", "rrTextRep is null.");
InvokeMethodOptions options = new InvokeMethodOptions();
options.Timeout = new TimeSpan(0,0,0,5);
ManagementClass rrClass = new
ManagementClass(@"\\"+ System.Environment.MachineName
+@"\root\MicrosoftDNS","MicrosoftDNS_ResourceRecord",null);
//Get an input parameters object for this method
ManagementBaseObject inParams =
rrClass.GetMethodParameters("CreateInstanceFromTextRepresentation");
//Fill in input parameter values
inParams["DnsServerName"] = null; //Don't need.
inParams["ContainerName"] = zoneName;
inParams["TextRepresentation"] = rrTextRep;
//Execute the method
try
{
ManagementBaseObject outObject = rrClass.InvokeMethod
("CreateInstanceFromTextRepresentation", inParams, null);
PropertyDataCollection outProperties = outObject.Properties;
foreach (PropertyData outProperty in outProperties)
{
Console.WriteLine("Property = " + outProperty.Name);
}
}
catch
{
throw new ApplicationException
("CreateInstanceFromTextRepresentationmethod failed.");
}
} // End CreateInstanceFromTextRepresentation Method.