diff --git a/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs b/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs index df8c35f3..6356245a 100644 --- a/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs +++ b/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs @@ -1076,8 +1076,41 @@ namespace DnsServerCore.Dns.ZoneManagers } if (zoneInfo is null) - throw new DnsServerException("Failed for clone the zone: zone already exists."); + throw new DnsServerException("Failed to clone the zone: zone already exists."); + //copy zone options + zoneInfo.Disabled = sourceZoneInfo.Disabled; + + if (zoneInfo.Type == AuthZoneType.Primary) + { + zoneInfo.ZoneTransfer = sourceZoneInfo.ZoneTransfer; + zoneInfo.ZoneTransferNameServers = sourceZoneInfo.ZoneTransferNameServers; + zoneInfo.ZoneTransferTsigKeyNames = sourceZoneInfo.ZoneTransferTsigKeyNames; + + zoneInfo.Notify = sourceZoneInfo.Notify; + zoneInfo.NotifyNameServers = sourceZoneInfo.NotifyNameServers; + + zoneInfo.Update = sourceZoneInfo.Update; + zoneInfo.UpdateIpAddresses = sourceZoneInfo.UpdateIpAddresses; + + { + Dictionary>> updateSecurityPolicies = new Dictionary>>(sourceZoneInfo.UpdateSecurityPolicies.Count); + + foreach (KeyValuePair>> sourceSecurityPolicy in sourceZoneInfo.UpdateSecurityPolicies) + { + Dictionary> policyMap = new Dictionary>(); + + foreach (KeyValuePair> sourcePolicyMap in sourceSecurityPolicy.Value) + policyMap.Add(sourcePolicyMap.Key.Substring(0, sourcePolicyMap.Key.Length - sourceZoneName.Length) + zoneName, sourcePolicyMap.Value); + + updateSecurityPolicies.Add(sourceSecurityPolicy.Key, policyMap); + } + + zoneInfo.UpdateSecurityPolicies = updateSecurityPolicies; + } + } + + //copy records List sourceRecords = new List(); ListAllZoneRecords(sourceZoneName, sourceRecords);