Creating a Zone
Creating a zone with the DNS
Provider is
a straightforward operation. You need to get a WMI object for the DNS
namespace, instantiate an object from the
MicrosoftDNS_Zone class, and call
CreateZone on that object. The next example shows
how to do this:
strNewZone = "movie.edu."
strServer = "terminator.movie.edu"
on error resume next
set objDNS = GetObject("winMgmts:\\" & strServer & "\root\MicrosoftDNS")
set objDNSZone = objDNS.Get("MicrosoftDNS_Zone")
strNull = objDNSZone.CreateZone(strNewZone,0,TRUE)
if Err then
WScript.Echo "Error occurred creating zone: " & Err.Description
else
WScript.Echo "Zone created . . . "
end ifThe three parameters we passed into CreateZone
include the zone name, the zone type flag, and the AD-integrated
flag. A zone type of 0 creates a primary zone.
When the AD-integrated flag is set to true, the primary zone is
AD-integrated; if it is false, it is a standard primary. At the time
of this writing, Microsoft had conflicting documentation about these
parameters and their valid values. Refer to the MSDN Library for more
information; hopefully, they’ll get it straight
eventually.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access