December 2003
Intermediate to advanced
416 pages
13h 50m
English
Configuring a zone is not too different from configuring a name
server. The primary difference is in how you instantiate a
MicrosoftDNS_Zone object. In order to use the
Get method on a WMI object, you have to specify
the keys for the class you want to instantiate. For the
MicrosoftDNS_Zone class, the keys include
ContainerName, DnsServerName,
and Name. In this case,
ContainerName and Name are both
the name of the zone. We retrieve DnsServerName by
getting a MicrosoftDNS_Server object as
we’ve done earlier in the chapter.
The following example lists all of the properties of the
movie.edu zone before it modifies the
AllowUpdate property and commits the change:
strZone = "movie.edu." strServer = "terminator.movie.edu" on error resume next set objDNS = GetObject("winMgmts:\\" & strServer & "\root\MicrosoftDNS") set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""") set objDNSZone = objDNS.Get("MicrosoftDNS_Zone.ContainerName=""" & strZone & _ """,DnsServerName=""" & objDNSServer.Name & _ """,Name=""" & strZone & """") ' List all of the properties of the zone Wscript.Echo objDNSZone.Name for each objProp in objDNSZone.Properties_ if IsNull(objProp.Value) then Wscript.Echo " " & objProp.Name & " : NULL" else if objProp.IsArray = TRUE then For I = LBound(objProp.Value) to UBound(objProp.Value) wscript.echo " " & objProp.Name & " : " & objProp.Value(I) next else wscript.echo " " & objProp.Name & " : " & objProp.Value end if end if next ' Modify the zone objDNSZone.AllowUpdate ...Read now
Unlock full access