Please help on create DNS zone with WMI. Thanks!

DavidW

Distinguished
Apr 22, 2004
9
0
18,510
Archived from groups: microsoft.public.win2000.dns (More info?)

I found zonetype is really strange, someone mentions zonetype need to be
different for win 2003 and win 2000, I am using win 2000, I use the
following code to create dns zone:

ManagementScope oScope = new
ManagementScope("\\\\"+serverName+"\\ROOT\\MicrosoftDNS");
ManagementPath Path = new ManagementPath("MicrosoftDNS_Zone");
ManagementClass DnsZoneClass = new ManagementClass(oScope, Path,
null);

ManagementBaseObject InputParams =
DnsZoneClass.GetMethodParameters("CreateZone");
InputParams["ZoneName"] = zoneName;
InputParams["ZoneType"] = zoneType;
if(dataFileName!="")
InputParams["DataFileName"] = dataFileName;
ManagementBaseObject OutParams =
DnsZoneClass.InvokeMethod("CreateZone", InputParams, null);

as I read from other post, zonetype should be 0 for primary zone on win
2003, and 1 on win 2000. I tried 0,1 and 2, it returns like this:

0 - Active Directory zone (create successuflly, but not I want, I need
primary zone)
1 - returns "general failure"
2 - returns "invalid parameter"

Any idea? I have two DNS server, I need the code to create primary zone on
first server, and second zone on second server, can I do that?


Thanks for help!
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.dns (More info?)

On Thu, 16 Jun 2005 11:26:56 -0700, "davidw" <davidw@affinisys.com>
wrote:

>I found zonetype is really strange, someone mentions zonetype need to be
>different for win 2003 and win 2000, I am using win 2000, I use the
>following code to create dns zone:
>
> ManagementScope oScope = new
>ManagementScope("\\\\"+serverName+"\\ROOT\\MicrosoftDNS");
> ManagementPath Path = new ManagementPath("MicrosoftDNS_Zone");
> ManagementClass DnsZoneClass = new ManagementClass(oScope, Path,
>null);
>
> ManagementBaseObject InputParams =
>DnsZoneClass.GetMethodParameters("CreateZone");
> InputParams["ZoneName"] = zoneName;
> InputParams["ZoneType"] = zoneType;
> if(dataFileName!="")
> InputParams["DataFileName"] = dataFileName;
> ManagementBaseObject OutParams =
>DnsZoneClass.InvokeMethod("CreateZone", InputParams, null);
>
>as I read from other post, zonetype should be 0 for primary zone on win
>2003, and 1 on win 2000. I tried 0,1 and 2, it returns like this:
>
>0 - Active Directory zone (create successuflly, but not I want, I need
>primary zone)
>1 - returns "general failure"
>2 - returns "invalid parameter"
>
>Any idea? I have two DNS server, I need the code to create primary zone on
>first server, and second zone on second server, can I do that?

Cam you use DNSCMD instead? Maybe in a shell.

Jeff
 

DavidW

Distinguished
Apr 22, 2004
9
0
18,510
Archived from groups: microsoft.public.win2000.dns (More info?)

I don't feel it is good to do all those operations in a shell. And do you
think there is a dnscmd under win 2000?

"Jeff Cochran" <jeff.nospam@zina.com> wrote in message
news:42b2b1e2.28686781@msnews.microsoft.com...
> On Thu, 16 Jun 2005 11:26:56 -0700, "davidw" <davidw@affinisys.com>
> wrote:
>
> >I found zonetype is really strange, someone mentions zonetype need to be
> >different for win 2003 and win 2000, I am using win 2000, I use the
> >following code to create dns zone:
> >
> > ManagementScope oScope = new
> >ManagementScope("\\\\"+serverName+"\\ROOT\\MicrosoftDNS");
> > ManagementPath Path = new ManagementPath("MicrosoftDNS_Zone");
> > ManagementClass DnsZoneClass = new ManagementClass(oScope,
Path,
> >null);
> >
> > ManagementBaseObject InputParams =
> >DnsZoneClass.GetMethodParameters("CreateZone");
> > InputParams["ZoneName"] = zoneName;
> > InputParams["ZoneType"] = zoneType;
> > if(dataFileName!="")
> > InputParams["DataFileName"] = dataFileName;
> > ManagementBaseObject OutParams =
> >DnsZoneClass.InvokeMethod("CreateZone", InputParams, null);
> >
> >as I read from other post, zonetype should be 0 for primary zone on win
> >2003, and 1 on win 2000. I tried 0,1 and 2, it returns like this:
> >
> >0 - Active Directory zone (create successuflly, but not I want, I need
> >primary zone)
> >1 - returns "general failure"
> >2 - returns "invalid parameter"
> >
> >Any idea? I have two DNS server, I need the code to create primary zone
on
> >first server, and second zone on second server, can I do that?
>
> Cam you use DNSCMD instead? Maybe in a shell.
>
> Jeff